关于为select对象建立option的! 用new Option("text","value")http://www.sayee.com/s.htm 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>function e(){ var op=null; var op2=null; for(var x=1;x<10;x++) { op=document.createElement('OPTION'); op2=document.createElement('OPTION'); op.text='options'+x; op.value=x; sel1.add(op); op2.text='options'+x; op2.value=x; sel2.add(op2,0); }}</script><select id=sel1 name=sel1></select><select id=sel2 name=sel2></select><a href="#" onclick=e()>click</a> <script language=javascript>function addOption(){ var o = document.createElement("option"); o.innerText = "new option"; o.value = "testValue"; document.all.testSelect.appendChild(o);}</script><select id=testSelect onchange="alert(this.options[this.selectedIndex].value)"><option value=test>option 1</select><button onclick=addOption()>new option</button> 建立option对象我都会,只是觉得建立一个option对象只能供一个select对象使用,有点奇怪,所以提出来让大家指点一下,不过可能是由于我说不清楚啦,所以答案都不是我想要的,只是看了swans(swan.net)的贴子后,发现他也是要分开建立option对象的,所以可能就是要分开建立的吧.不过无论怎么说,都谢谢大家啦! 如何得到a中的文字 关于把div层,拖现IE浏览器的想法...... javacript中如何获取select组件的文本(不是Code),value返回的是Code 怎么勾选动态生成的checkbox 怎样在所有的浏览器都屏蔽菜单栏、工具栏、地址栏和状态栏 [求助]一拍的的注册验证是怎么实现的? 想深入系统的学习一下javascript,哪位朋友帮忙介绍基本这方面的电子图书的下载,谢谢~ 寻找CRM源代码 客户端的问题!大伙帮我看看怎么解决? 难度挺大的问题,和一般的是不一样的,关于拖动 新手问题,请帮忙 保存框架页面
{
var op=null;
var op2=null;
for(var x=1;x<10;x++)
{
op=document.createElement('OPTION');
op2=document.createElement('OPTION');
op.text='options'+x;
op.value=x;
sel1.add(op);
op2.text='options'+x;
op2.value=x;
sel2.add(op2,0);
}
}
</script><select id=sel1 name=sel1>
</select>
<select id=sel2 name=sel2>
</select>
<a href="#" onclick=e()>click</a>
function addOption()
{
var o = document.createElement("option");
o.innerText = "new option";
o.value = "testValue";
document.all.testSelect.appendChild(o);
}
</script>
<select id=testSelect onchange="alert(this.options[this.selectedIndex].value)">
<option value=test>option 1
</select>
<button onclick=addOption()>new option</button>