Java脚本中的下拉列表-trskaran [英] Drop down list in java script - trskaran

查看:54
本文介绍了Java脚本中的下拉列表-trskaran的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>
<head>
<script type="text/javascript">
function setOptions(chosen, selbox) {

selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}

if (chosen == "1") {
	selbox.options[selbox.options.length] = new Option('--Select--','');
	for($i=1; $i<=5; $i++)
	{
		$a=$i+10;
		selbox.options[selbox.options.length] = new Option($a,$a);	
	}
}

if (chosen == "2") {
    selbox.options[selbox.options.length] = new Option('--Select--','');
	for($i=1; $i<=5; $i++)
	{
		$a=$i+20;
		selbox.options[selbox.options.length] = new Option($a,$a);		
	}
}

if (chosen == "3") {
    selbox.options[selbox.options.length] = new Option('--Select--','');
	for($i=1; $i<=5; $i++)
	{
		$a=$i+30;
		selbox.options[selbox.options.length] = new Option($a,$a);		
	}
}

if (chosen == "4") {
    selbox.options[selbox.options.length] = new Option('--Select--','');
	for($i=1; $i<=5; $i++)
	{
		$a=$i+40;
		selbox.options[selbox.options.length] = new Option($a,$a);		
	}
}

if (chosen == "5") {
    selbox.options[selbox.options.length] = new Option('--Select--','');
	for($i=1; $i<=5; $i++)
	{
		$a=$i+50;
		selbox.options[selbox.options.length] = new Option($a,$a);		
	}
}

}
 </script>
</head>
 <body>
<form name="myform">
  <select name="optone"  önChange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value,document.myform.opttwo);">
    <option value=" " selected="selected">-------- Select --------</option>
    <script type="text/javascript">
	  for($i=1; $i<=5; $i++)
	  {
	    document.write("<option value="+$i+">"+$i+"</option>")
	  
	  }
	</script>	
   </select> 

   <select name="opttwo">
    <option value=" " selected="selected">Please select one of the options above first</option>
   </select> 
 </form>
  </body>
 </html>

推荐答案

i = 1 ;


i< = 5 ;
i<=5;


i ++) {


这篇关于Java脚本中的下拉列表-trskaran的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆