没有写一个弹出页面进行返回什么的。下面的这个效果也能表示出来。将取text框的值给select赋值,改为从子页面带回的值赋值即可!
变成这样window.opener.document.getElementById("Select1").selectedIndex =子页面带回的值
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<script type="text/javascript">
function selectItem() {
document.getElementById("Select1").selectedIndex = parseInt(document.getElementById("Text1").value);
}
</script>
<body>
<select id="Select1">
<option value="0">0</option>
<option value="1">1</option>
</select>
<input id="Text1" type="text" />
<input id="Button1" type="button" value="button" onclick="selectItem()" /></body>
</html>
变成这样window.opener.document.getElementById("Select1").selectedIndex =子页面带回的值
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<script type="text/javascript">
function selectItem() {
document.getElementById("Select1").selectedIndex = parseInt(document.getElementById("Text1").value);
}
</script>
<body>
<select id="Select1">
<option value="0">0</option>
<option value="1">1</option>
</select>
<input id="Text1" type="text" />
<input id="Button1" type="button" value="button" onclick="selectItem()" /></body>
</html>
<select id="Select1" disabled="disabled" >
<option value="0">0</option>
<option value="1">1</option>
</select>
var parentWin = window.opener;
var obj = parentWin.document.getElementById("selectId");if(true){
pt_dp.options[0].selected = true;
}else{
pt_dp.options[1].selected = true;
}
父页面的select
<select id="selectId" disabled="disabled" >
<option value="0">0 </option>
<option value="1">1 </option>
</select>
我原来用input就获取不到值。它好像不被提交的
input设置成readonly(不同于disable,readonly可以取到值)
<option value=""></option>
<option value="1" selected>1</option>
</select>