日期:2014-05-16  浏览次数:20329 次

[求助]改变父窗口 列表框选项 option
<script   language= "JavaScript "   type= "text/javascript ">
function   selectfenlei(Obj)
{alert(Obj);
var   b=window.opener.document.all.form1.select2;
alert(b.value);
b.options.add(new   Option(Obj,Obj));


}
</script>

<a   href=#     onclick= "javascript:selectfenlei(this.innerText); "> 美图欣赏 </a>

------解决方案--------------------
function selectfenlei(Obj)
{alert(Obj);
var b=parent.document.getElementById( "select2 ");
// clear all
b.options.length = 0;
// add
b.options.add(new Option(Obj,Obj));
}
------解决方案--------------------
<!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>

<body>
<form name= "form1 ">
<select name= "n1 ">
<option value= "xx1 "> xxx </option>
<option selected= "selected " value= "yy1 "> yyy </option>
<option value= "zz1 "> zzz </option>
</select>
<input type= "button " value= "add " onclick= "add(); " />
</form>

</body>
</html>

<script type= "text/javascript ">

function add()
{
document.form1.n1.options.add(new Option( "mmm ", "mm "));

}

</script>

--
添加option