日期:2014-05-17  浏览次数:20779 次

请高手讲解,使用(*.asp语言)我代码的例子如何使用定义实现列表/菜单的创建赋值。
<html>
<head>
<script language="javascript" type="text/javascript">
function aaa()
{
var a = document.getElementById("shi1");
function set_select(a,b,vf,tf)
{
for (var i = 0,n = a.length; i < n; i++)
{
var c = document.createElement("option");
c.text = b[i][tf];
c.value = b[i][vf];
if (a.options.add)
{
a.options.add(c);
}
else
{
a.appendChild(c);
}
}
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<form name="form1" method="post" action="">
<table align="center">
<tr>
<td><select name="shi1" id="shi1"><select></td>
<td><input name="chuang" type="button" id="chuang" onClick="aaa()" value="显示并创建" /></td>
</tr>
</table>
</form>
</body>
</html>
我的QQ:448571358请前辈也留下QQ,我真心结交。【上边的代码功能我怎么试也不成,难住我了。望前辈指点。】
希望前辈能把我的代码给修改下,能实现菜单列表自动赋值1、2、3、4、5、6、7、8、9、10列拉值,这值要自动循环赋。【望路过的前辈,留步教我。】

------解决方案--------------------
循环创建option 然后循环append? 说实话,没特别明白你啥意思。。。
------解决方案--------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<form name="form1" method="post" action="">
<table align="center">
<tr>
<td><select name="shi1" id="shi1"><select></td>
<td><input name="chuang" type="button" id="chuang" onClick="aaa()" value="显示并创建" /></td>
</tr>
</table>
</form>
<script language="javascript" type="text/javascript">
function aaa()
{
var a = document.getElementById("shi1");

for (var i = 1; i < 11; i++)
{
var c = document.createElement("option");
c.text = i;
c.value = i;
if (a.options.add)
{
a.options.add(c);
}
else
{
a.appendChild(c);

}
}
}


</script>
</body>
</html>







这个意思?