»
Tiếng AnhTiếng PhápTiếng Việt

In - Tạo menu sổ dọc - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Ứng dụng » Công cụ xuất » Tạo menu sổ dọc
URL: https://www.javascriptbank.com/dropdown-menu-maker.html

Tạo menu sổ dọc © JavaScriptBank.comMột chương trình tạo trình đơn sổ dọc đơn giản trên trang web. Sau khi tạo xong bạn có thể dán mã HTML vào trang web khác của mình.

Phiên bản đầy đủ: jsB@nk » Ứng dụng » Công cụ xuất » Tạo menu sổ dọc
URL: https://www.javascriptbank.com/dropdown-menu-maker.html



CSS
<style type="text/css"><!--body, table, tr, td {background:silver;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:9pt;line-height:.8;text-align:center;}form, select, option, textarea {font-family:Helvetica,Univers,Arial,sans-serif;font-size:9pt;}legend {font-family:Helvetica,Univers,Arial,sans-serif;font-size:9pt;font-weight:bold;}input {font-family:Helvetica,Univers,Arial,sans-serif;font-size:9pt;}h1 {font-family:Helvetica,Univers,Arial,sans-serif;font-size:13pt;font-weight:bold;}--></style><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<script type="text/JavaScript"><!--//Script by Roland Toyfunction buildMenu() {//top (no button):if (document.define.target[0].checked) {if (document.gonogo.g[1].checked) {document.display.showStuff.value +="<form name=\"" +document.form1.input1.value + "\">\n" + "<select name=\"" + document.form1.input2.value+"\" onChange=\""+"top.location.href=document."+document.form1.input1.value+"."+document.form1.input2.value+".options[document."+document.form1.input1.value+"."+document.form1.input2.value+"."+"selectedIndex].value\""+">\n<option value=\""+"#"+"\">SELECT:<\/option>\n";}//top (with button):else if(document.define.target[0].checked) {if (document.gonogo.g[0].checked) {document.display.showStuff.value +="<form name=\"" +document.form1.input1.value + "\">\n" + "<select name=\"" + document.form1.input2.value + "\"> \n"+"<option value=\""+"#"+"\">SELECT:<\/option>\n"}}}//same (no button):else if(document.define.target[1].checked) {if (document.gonogo.g[1].checked) {document.display.showStuff.value +="<form name=\"" +document.form1.input1.value + "\">\n" + "<select name=\"" +document.form1.input2.value+"\" onChange=\""+"self.location.href=document."+document.form1.input1.value+"."+document.form1.input2.value+".options[document."+document.form1.input1.value+"."+document.form1.input2.value+"."+"selectedIndex].value\""+">\n<option value=\""+"#"+"\">SELECT:<\/option>\n";}//same (with button):else if(document.define.target[1].checked) {if (document.gonogo.g[0].checked) {document.display.showStuff.value +="<form name=\"" +document.form1.input1.value + "\">\n" + "<select name=\"" + document.form1.input2.value + "\"> \n"+"<option value=\""+"#"+"\">SELECT:<\/option>\n"}}}//popup (with button):else if (document.define.target[3].checked) {if (document.gonogo.g[0].checked) {document.display.showStuff.value +="<script type=\""+"text/JavaScript"+"\">\n\n"+"var popUp;\n\nfunction go(showUp) {\npopUp=window.open(showUp[showUp.selectedIndex].value,'doPop','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=200,height=200');\npopUp.focus();\n}\n<"+"/script>\n"+"<form name=\""+"list"+"\">\n"+"<select name=\""+"items"+"\">\n<option value=\""+"#"+"\">SELECT:<\/option>\n";}//popup (no button):else if (document.define.target[3].checked) {if (document.gonogo.g[1].checked) {document.display.showStuff.value +="<script type=\""+"text/JavaScript"+"\">\n\n"+"var popUp;\n\nfunction go(showUp) {\npopUp=window.open(showUp[showUp.selectedIndex].value,'doPop','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=200,height=200');\npopUp.focus();\n}\n<"+"/script>\n"+"<form name=\""+"list"+"\">\n"+"<select name=\""+"items"+"\" onChange=\""+"go(this.form.items.options)"+"\">\n<option value=\""+"#"+"\">SELECT:<\/option>\n";}}}//frameset (with button):else if (document.define.target[2].checked) {if (document.gonogo.g[0].checked) {document.display.showStuff.value +="<form name=\"" + document.form1.input1.value + "\">\n"+"<select name=\"" + document.form1.input2.value + "\"> \n"+"<option value=\""+"#"+"\">SELECT:<\/option>\n"}//frameset (no button):else if (document.define.target[2].checked) {if (document.gonogo.g[1].checked) {document.display.showStuff.value +="<form name=\"" + document.form1.input1.value + "\">\n"+"<select name=\"" +document.form1.input2.value+"\" onChange=\""+"parent."+document.form1.input3.value+".location.href=document."+document.form1.input1.value+"."+document.form1.input2.value+".options[document."+document.form1.input1.value+"."+document.form1.input2.value+"."+"selectedIndex].value\""+">\n<option value=\""+"#"+"\">SELECT:<\/option>\n";}}}}function add() {if (document.form2.input3.value != "") {document.display.showStuff.value +="<option value=\"" +document.form2.input3.value + "\">";}if (document.form2.input3.value != "") {document.display.showStuff.value +="" +document.form2.input4.value + "<\/option>"+"\n";}}function finish() {//top (no button):if (document.define.target[0].checked) {if (document.gonogo.g[1].checked) {document.display.showStuff.value +="" +"\<\/select>"+"\n"+"\<\/form>";}//top (with button):else if(document.define.target[0].checked) {if (document.gonogo.g[0].checked) {document.display.showStuff.value +="" +"\<\/select> <input type=\"" + "button"+"\" value=\""+"Go"+"\" onClick=\""+"top.location.href=document."+document.form1.input1.value+"."+document.form1.input2.value+".options[document."+document.form1.input1.value+"."+document.form1.input2.value+"."+"selectedIndex].value\""+">\n<\/form>";}}}//same (with button):else if(document.define.target[1].checked) {if (document.gonogo.g[0].checked) {document.display.showStuff.value +="" +"\<\/select> <input type=\"" + "button"+"\" value=\""+"Go"+"\" onClick=\""+"self.location.href=document."+document.form1.input1.value+"."+document.form1.input2.value+".options[document."+document.form1.input1.value+"."+document.form1.input2.value+"."+"selectedIndex].value\""+">\n<\/form>";}//same (no button):if (document.define.target[1].checked) {if (document.gonogo.g[1].checked) {document.display.showStuff.value +="" +"\<\/select>"+"\n"+"\<\/form>";}}}//frameset (with button):else if(document.define.target[2].checked) {if (document.gonogo.g[0].checked) {document.display.showStuff.value +="" +"\<\/select> <input type=\"" + "button"+"\" value=\""+"Go"+"\" onClick=\""+"parent."+document.form1.input3.value+".location.href=document."+document.form1.input1.value+"."+document.form1.input2.value+".options[document."+document.form1.input1.value+"."+document.form1.input2.value+"."+"selectedIndex].value\""+">\n\<\/form>\n";}//frameset (no button):if (document.define.target[2].checked) {if (document.gonogo.g[1].checked) {document.display.showStuff.value +="" +"\<\/select>"+"\n"+"\<\/form>";}}}//popup (with button):else if (document.define.target[3].checked) {if (document.gonogo.g[0].checked) {document.display.showStuff.value +="" +"\<\/"+"select>"+"\n<input type=\"" + "button"+"\" value=\""+"Go"+"\" onClick=\""+"go(this.form.items.options)"+"\">\n<\/form>";}//popup (no button):else if (document.define.target[3].checked) {if (document.gonogo.g[1].checked) {document.display.showStuff.value +="" +"\<\/select>"+"\n"+"\<\/form>";}}}}function Help() {document.display.showStuff.value = "Specify a target and whether the menu uses a GO button. Click OK.\n\nEnter FORM, SELECT, and FRAME names as indicated. Click OK.\n\nFor each menu item, enter a URL and menu name, then click ADD.\n\nClick FINISH when all menu items are added.\n\nHighlight the displayed code. Copy it in your HTML document.\n";}function tip() {//provide guidance:if (document.define.target[0].checked) {document.form1.input3.value ="Skip This";document.form1.input1.value ="";document.form1.input2.value ="";}else if (document.define.target[1].checked) {document.form1.input1.value ="";document.form1.input2.value ="";document.form1.input3.value ="Skip This";}else if (document.define.target[2].checked) {document.form1.input1.value ="";document.form1.input2.value ="";document.form1.input3.value ="";}else if (document.define.target[3].checked) {document.form1.input1.value ="Skip This";document.form1.input2.value ="Skip This";document.form1.input3.value ="Skip This";}}--></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<table border="0" cellpadding="1" cellspacing="1" summary="Define menu target and activation method."><tbody><tr><td valign="top"><form name="define"><fieldset><legend>Target</legend><input type="radio" name="target" value="t" checked="checked">Top <input type="radio" name="target" value="s">Same Window <input type="radio" name="target" value="wif">Frameset <input type="radio" name="target" value="pop">Popup&nbsp;&nbsp;</fieldset></form></td><td valign="top"><form name="gonogo"><fieldset><legend>Go Button</legend><input type="radio" name="g" value="g" checked="checked">Yes <input type="radio" name="g" value="ng">No&nbsp;&nbsp;&nbsp;<input type="button" value="OK" onclick="javascript:tip()">&nbsp;&nbsp;</fieldset></form></td></tr></tbody></table><table border="0" cellpadding="1" cellspacing="1" summary="Define form, frameset target, and display generated code."><tbody><tr><td valign="top"><form name="form1"><fieldset><legend>Menu Names</legend>&nbsp;Form: <input type="text" name="input1" size="10">&nbsp;&nbsp;&nbsp;Select: <input type="text" name="input2" size="10">&nbsp;&nbsp;&nbsp;Frame: <input type="text" name="input3" size="10">&nbsp;&nbsp;&nbsp;<input type="button" value="OK" onclick="javascript:buildMenu()"></fieldset></form></td></tr><tr><td>&nbsp;</td></tr><tr><td valign="top"><form name="form2"><fieldset><legend>Add Menu Items</legend>&nbsp;URL: <input type="text" name="input3" size="22">&nbsp;&nbsp;Menu Name: <input type="text" name="input4" size="12">&nbsp;&nbsp;<input type="reset" value="Add" onclick="javascript:add()"><input type="button" value="Finish" onclick="javascript:finish()"></fieldset></form></td></tr><tr><td valign="top" colspan="2"><form name="display"><textarea name="showStuff" rows="10" cols="80" wrap="off" readonly="readonly"></textarea><br>&nbsp;&nbsp;&nbsp;<input type="button" value="Highlight Code" onclick="this.form.showStuff.focus();this.form.showStuff.select()"><input type="reset" value="Clear"> <input type="button" value="Help" onclick="javascript:Help()"></form></td></tr></tbody></table><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->