js實現網頁多級串聯功能表代碼_javascript技巧

來源:互聯網
上載者:User

本文執行個體講述了js實現網頁多級串聯功能表。分享給大家供大家參考。具體如下:

這是大家在網頁上經常會見到的串聯功能表特效,不過這一個代碼是由JS來實現,將串聯功能表中的內容儲存在了JS數組中,為了頁面美觀,本次還美化了一下表格邊框,整體看上去更和諧實用了,多級的下拉式功能表對網頁設計來說比較實用。

運行效果如下圖所示:

線上示範地址如下:

http://demo.jb51.net/js/2015/js-table-select-menu-style-codes/

具體代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>多級串聯功能表</title><script type="text/javascript">var arr2 = new Array(4);arr2["數位裝置"] = new Array("數位相機","印表機");arr2["家用電器"] = new Array("電視機","電冰箱");arr2["禮品工藝"] = new Array("鮮花","綵帶");function removeinfo(classMenu){//將下拉框各選項清空 for (var i=0; i < classMenu.options.length; i++){ classMenu.options[i]=null; }}function changeMenu(classList,classMenu){ removeinfo(classMenu) for (var i=0; i < classList.length; i++){ classMenu[i]=new Option(classList[i],classList[i]); }}</script></head><body style="font-size:12px"><table width="487" height="333" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="top"><br> <br> <br> <br> <br> <table width="86%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#6699CC"> <form name="form1"> <tr bgcolor="#FFFFFF">  <td height="22" align="right">所屬類別:</td>  <td height="22" align="left"><select name="類別" id="類別" onChange="changeMenu(arr2[document.form1.類別.options[document.form1.類別.selectedIndex].text],document.form1.分類);">  <option selected>數位裝置</option>  <option>家用電器</option>  <option>禮品工藝</option>  </select>  <select name="分類" id="分類">  <option>數位相機</option>  <option>印表機</option>  </select></td> </tr> <tr bgcolor="#FFFFFF">  <td height="22" align="right">商品名稱:</td>  <td height="22" align="left"><input name="商品名稱" type="text" id="商品名稱" size="30" maxlength="50"></td> </tr> <tr bgcolor="#FFFFFF">  <td height="22" align="right">會員價:</td>  <td height="22" align="left"><input name="會員價" type="text" id="會員價" size="10"></td> </tr> <tr bgcolor="#FFFFFF">  <td height="22" align="right">提供廠商:</td>  <td height="22" align="left"><input name="提供廠商" type="text" id="提供廠商" size="30" maxlength="50"></td> </tr> <tr bgcolor="#FFFFFF">  <td height="22" align="right">商品簡介:</td>  <td height="22" align="left"><textarea name="商品簡介" cols="35" rows="4" id="商品簡介"></textarea></td> </tr> <tr bgcolor="#FFFFFF">  <td height="22" align="right">商品數量:</td>  <td height="22" align="left"><input name="商品數量" type="text" id="商品數量" size="10"></td> </tr> <tr bgcolor="#FFFFFF">  <td height="22" colspan="2" align="center"><input name="add" type="submit" id="add2" value="添 加">  <input type="reset" name="Submit2" value="重 置"></td> </tr> </form> </table></td> </tr></table></body></html>

希望本文所述對大家的javascript程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.