日期:2014-05-17 浏览次数:21370 次
<html>
<head>
<script type="text/javascript">
function GenSelectListEx()
{
var curobj=document.getElementById("id_video_format");
for(var i = 0; i < 5; i++)
{
var optionelement = new Option("111", "111");
curobj.options.add(optionelement);
}
}
window.onload=function(){
GenSelectListEx();
}
</script>
</head>
<body>
<div id="my_div" style="width: 750px; margin-top: 10px; text-align: left; overflow: hidden;">
<select name="video_format" class="td_select" id="id_video_format">
</select>
</div>
</body>
</html>
------解决方案--------------------
<html>
<head>
<script type="text/javascript">
function GenSelectListEx() {
var curobj = document.getElementById("id_video_format");
for (var i = 0; i < 5; i++) {
var optionelement = document.createElement("option");
//optionelement.style.cssText ="value:"options[i].optionValue";";
optionelement.text = "1111";
try {
curobj.add(optionelement, null);
} catch(e) {
curobj.add(optionelement);
}
}
}
</script>
</head>
<body>
<div id="my_div" style="width: 750px; margin-top: 10px; text-align: left; overflow: hidden;">
<select name="video_format" class="td_select" id="id_video_format">
</select>
</div>
<script type="text/javascript">
GenSelectListEx();
</script>
</body>
</html>