<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function aa()
{
var ivrs="aa,bb,cc,dd,ee"; //这是从后台传过来的不定数量
var ivrArray = ivrs.split(",");
for(var i = 0; i < ivrArray.length; i++){
var ivr=ivrArray[i]; //ivr
alert(ivr); //怎么把ivr 放到 select 里呀
}
}
</script>
<body onload="aa();">
<select name="ivrname">
<option value="aa">aa</option>
<option value="bb">bb</option> </select>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function aa()
{
var ivrs="aa,bb,cc,dd,ee"; //这是从后台传过来的不定数量
var ivrArray = ivrs.split(",");
for(var i = 0; i < ivrArray.length; i++){
var ivr=ivrArray[i]; //ivr
alert(ivr); //怎么把ivr 放到 select 里呀
}
}
</script>
<body onload="aa();">
<select name="ivrname">
<option value="aa">aa</option>
<option value="bb">bb</option> </select>
</body>
</html>
y.text='aa';
y.value='aa';
document.getElementsByName("ivrname")[0].add(y);
function aa()
{
var ivrs="aa,bb,cc,dd,ee"; //这是从后台传过来的不定数量
var ivrArray = ivrs.split(",");
var select = document.getElementsByName("ivrname")[0];
for(var i = 0; i < ivrArray.length; i++){
var ivr=ivrArray[i]; //ivr
var tmp = document.createElement("option");
tmp.value=ivr;
tmp.text=ivr;
select.add(tmp);
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function aa()
{
var ivrs="aa,bb,cc,dd,ee"; //这是从后台传过来的不定数量
var ivrArray = ivrs.split(",");
for(var i = 0; i < ivrArray.length; i++){
var ivr=ivrArray[i];
var opt = document.createElement("option");
opt.value = opt.text = ivr;
document.getElementsByName("ivrname")[0].appendChild(opt);
}
}
</script>
<body onload="aa();">
<select name="ivrname">
<option value="aa">aa</option>
<option value="bb">bb</option> </select>
</body>
</html>
==》
opt.value = opt.innerHTML = ivr;
上边的ie不支持