如何动态添加<option>选项 http://www.csdn.net/Expert/topicview.asp?id=797931 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var input_node = document.createElement("<input type=radio>") IE和NS通用的方法:<form name=f><select name=s></selct><input type=button onclick="a()" value=add></form><script>var i=0function a(){b=document.f.svar opt=new Option("text"+ i,"value"+i,true,true)b.options[b.options.length] = opti++}</script> <select id=demo></select><script>var option_node = document.createElement("OPTION")option_node.innerText="hehe"demo.appendChild(option_node)</script> <script>var _obj=document.all("test");var _o=document.createElement("Option");_o.text="text";_o.value="1";_obj.add(_o);</script> 用javascript实现,the_select为操作的select框,the_array为一个数组,用来赋值,其实不用也可以。function setOptionText(the_select, the_array){the_select.options.length = the_array.length-1;for (loop=0; loop < the_array.length-1; loop++) { the_select.options[loop].text = the_array[loop]; the_select.options[loop].value = the_array[loop]; }} 急...js 单击图片放大时,如何让图片以单击的地方为中心放大 显示和隐藏div的问题 谁是聪明人~一个问题测试一下~ 上传文件清空问题!! url传过来参数encode加密的问题 一个鼠标拖动页面的问题难题!!急!在线等~~~~~ 如何将父窗口的参数传递给子窗口? 一个简单的问题,怎么使首页最大化? 请教图像预载是什么意思,给我举个例子 新手在线等!!!路径问题!!着急 如何用正则表达式判断一个ip 怎么样的到没有在样式表里面设定的值.
<form name=f>
<select name=s></selct>
<input type=button onclick="a()" value=add>
</form>
<script>
var i=0
function a()
{
b=document.f.s
var opt=new Option("text"+ i,"value"+i,true,true)
b.options[b.options.length] = opt
i++
}
</script>
<script>
var option_node = document.createElement("OPTION")
option_node.innerText="hehe"
demo.appendChild(option_node)
</script>
var _obj=document.all("test");
var _o=document.createElement("Option");
_o.text="text";
_o.value="1";
_obj.add(_o);
</script>
{
the_select.options.length = the_array.length-1;
for (loop=0; loop < the_array.length-1; loop++)
{
the_select.options[loop].text = the_array[loop];
the_select.options[loop].value = the_array[loop];
}
}