146、下拉菜单自动生成

146、下拉菜单自动生成

脚本说明:

第一步:把如下代码加入<body>区域中

<script language="javascript">

// Location of this script:

// http://www.qiksearch.com/javascripts/menugen.htm

 

var no_options;

 

document.write('<table cellspacing="5" cellpadding="5" style="border:2 solid #808080" align="center"><tr><td>');

document.write('<form name="qiksearch">');

if(navigator.appName=="Microsoft Internet Explorer")

{

 document.write('<font face="verdana,arial,helvetica" size="-1" color="#000000">显示<select name="select_items" onchange="javascript:showItems(this.document.qiksearch.select_items.value)" style="font-size:8pt">');

 for(var i=1; i<=30; i++)

 {

  document.write('<option value="' + i + '">' + i + '</option>');

 }

 this.document.qiksearch.select_items.selectedIndex = 4;

 document.write('</select> 链接.<br><br>');

}

 

document.write('<b>下拉菜单名称:</b><br><br>');

document.write('<input type="text" value="Select" name="combo_caption" size="30" style="height:20; border:1 solid #000000">');

document.write('<br><br><b>下拉菜单内容 :</b><br><br>');

document.write('<div id="items">');

for(var i=1; i<=5; i++)

{

 document.write('Option : <input type="text" size="12" name="option' + i + '" style="height:20; border:1 solid #000000"> Link to : <input type="file" name="linkto' + i + '" size="15" style="height:20; border:1 solid #000000"><br>');

}

document.write('</div>');

document.write('<br><center><input type="button" name="qiksearch_submit" value="显示代码" onclick="display()" style="font-family:verdana,arial,helvetica; font-size:8pt; height:20; width:48%; background:#EFEFEF; border:1 solid #808080; cursor:hand"> <input type="reset" onclick="javascript:location.reload();" style="font-family:verdana,arial,helvetica; font-size:8pt; height:20; width:48%; background:#EFEFEF; border:1 solid #808080; cursor:hand"></center>');

document.write('</font></form>');

 

document.write('</td></tr></table>');

 

function showItems(n)

{

 var item_disp = "";

 for(var i=0; i<n; i++)

 {

  item_disp += 'Option : <input type="text" size="12" name="option' + (i+1) + '" style="height:20; border:1 solid #000000"> Link to : <input type="file" name="linkto' + (i+1) + '" size="15" style="height:20; border:1 solid #000000"><br>';

 }

 no_options=n;

 this.document.all.items.innerHTML = item_disp;

}

 

if(navigator.appName=="Microsoft Internet Explorer")

{

 no_options = this.document.qiksearch.select_items.value;

}

else

{

 no_options = 5;

}

 

function display() {

   DispWin=window.open('','NewWin',

   'toolbar=no,status=no,width=500,height=375')

   message="<font face=arial,verdana,helvetica size=-2 color=#000000><b><!--Made with Qiksearch MenuGen-->";

   message += "<br><script language="javascript" type="text/javascript">";

   message += "<br>function go()";

   message += "<br>{";

   message += "<br> if (document.selecter.select1.options[document.selecter.select1.selectedIndex].value != "none")";

   message += "<br> {";

   message += "<br>  location = document.selecter.select1.options[document.selecter.select1.selectedIndex].value";

   message += "<br> }";

   message += "<br>}";

   message += "<br></script>";

   message += "<br>";

   message += "<br><script language="JavaScript" type="text/javascript">";

   message += "<br>document.write('<form name="selecter"><select name="select1">');";

   message += "<br>document.write('<option value=none>" + this.document.qiksearch.combo_caption.value + "</option>');";

   message += "<br>document.write('<option value=none>--------------------</option>');";

    for(var i=1; i<=no_options; i++)

    {

     message += "<br>document.write('<option value="" + eval('this.document.qiksearch.linkto' + i + '.value') + "">" + eval('this.document.qiksearch.option' + i + '.value') + "</option>');";

    }

   message += "<br>document.write('</select>');";

   message += "<br>document.write('<input type="button" value="Go" onclick="go()">');";

   message += "<br>document.write('</form>');";

   message += "<br></script>";

  

   DispWin.document.write(message);

}

 

 

</script>

 

第二步:把<body>中的内容改为:

<body bgcolor="#fef4d9" onload="this.document.qiksearch.select_items.selectedIndex = 4">

 

Write a comment

Comments: 0