这么做是不行的,
你create出来的op不是主窗口的元素,添加是不对的。<Select size=6 id="select1"> </Select>
<Script language="javascript">
window.showModalDialog("dialog.htm",document);
</cript>//dialog.htm
...
pd = window.dialogArguments;
op = pd.createElement("Option");
op.text ="xxx";
op.value = "yyy";
pd.getElementById("select1").add(op);
你create出来的op不是主窗口的元素,添加是不对的。<Select size=6 id="select1"> </Select>
<Script language="javascript">
window.showModalDialog("dialog.htm",document);
</cript>//dialog.htm
...
pd = window.dialogArguments;
op = pd.createElement("Option");
op.text ="xxx";
op.value = "yyy";
pd.getElementById("select1").add(op);
***********************************
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>测试页</title>
</head><body>
<form name=form1>
<input name="t1">
<input value="确定" type=button onclick="return check()">
</form>
<script language="javascript">
<!--
function check()
{
var t1=form1.t1.value;
k=showModalDialog("dialog.htm",t1,"dialogWidth:400px;status:no;dialogHeight:300px");
//把输入的值传过去
alert("你在showModalDialog窗口中选择的值是:"+k);//k为接收传回来的值
}
//-->
</script></body></html>dialog.htm
******************************************
<select name=s2 onchange="c(this.value)"></select>
<script language>
var k=window.dialogArguments; //中就是接收showModalDialog的第二个参数,可是是变量,对象即数组等
s2.add(new Option("text1","text1"));
s2.add(new Option("text2","text2"));s2.add(new Option(k,k));function c(value){
window.returnValue=value;
window.close();
}
</script>
<body>
<script language="javascript">
<!--
var s1=document.createElement("select");
s1.add(new Option("aaaaaaaa","a"));
s1.add(new Option("bbbbbbbb","b"));
document.body.appendChild(s1);
//-->
</script>
</body>
</html>