Phiên bản đầy đủ: jsB@nk » Biểu mẫu » Trình đơn xổ dọc » Hộp chọn động
URL: https://www.javascriptbank.com/dynamic-combo-box.html
Tạo ra hộp chọn dẫn đến các liên kết khác.
Phiên bản đầy đủ: jsB@nk » Biểu mẫu » Trình đơn xổ dọc » Hộp chọn động
URL: https://www.javascriptbank.com/dynamic-combo-box.html
<script><!-- //DEFINE the group of links for display in the combo//EXTEND each array and its elements as needed//BE sure to follow the pattern revealed belowvar combo1=new Array()combo1[0]=new Option("Game.TrucTuyen.org","http://Game.TrucTuyen.org")combo1[1]=new Option("JavaScriptBank.com","http://JavaScriptBank.com")combo1[2]=new Option("Freewarejava.com","http://www.freewarejava.com")combo1[3]=new Option("Free Web Templates","http://www.freewebtemplates.com")combo1[4]=new Option("Web Monkey","http://www.webmonkey.com")var combo2=new Array()combo2[0]=new Option("CNN","http://www.cnn.com")combo2[1]=new Option("MSNBC","http://www.msnbc.com")combo2[2]=new Option("BBC News","http://news.bbc.co.uk")combo2[3]=new Option("ABC News","http://www.abcnews.com")var combo3=new Array()combo3[0]=new Option("Hollywood.com","http://www.hollywood.com")combo3[1]=new Option("MTV","http://www.mtv.com")combo3[2]=new Option("ETOnline","http://etonline.com")var cacheobj=document.dynamiccombo.stage2function populate(x){for (m=cacheobj.options.length-1;m>0;m--)cacheobj.options[m]=nullselectedarray=eval(x)for (i=0;i<selectedarray.length;i++)cacheobj.options[i]=new Option(selectedarray[i].text,selectedarray[i].value)cacheobj.options[0].selected=true}function gothere(){location=cacheobj.options[cacheobj.selectedIndex].value}//SHOW first combo by defaultpopulate(combo1)//--></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name="dynamiccombo"><select name="stage2" size="1"><option value="#">This is a Place Holder</option><option value="#">This is a Place Holder</option><option value="#">This is a Place Holder</option></select><input type="button" name="test" value="Go!"onClick="gothere()"></form><!--SET up your links, and pass in the name of the group (ie: combo1) you wish to display for the link in question--><a href="javascript:populate(combo1)">Webmaster sites</a> | <a href="javascript:populate(combo2)">News sites</a> | <a href="javascript:populate(combo3)">Entertainment</a><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->