1.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Page1</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function textdisable() {
if(radiobutton[0].checked){textfield1.disabled=false;textfield2.disabled=true;}
else {textfield1.disabled=true;textfield2.disabled=false;}
}
</script>
</head>
<body>
<table width="240" border="1">
<tr>
<td width="67"><input name="radiobutton" type="radio" value="AAAA" onclick="textdisable()">
AAAA</td>
<td width="157"><input type="text" name="textfield1"></td>
</tr>
<tr>
<td><input name="radiobutton" type="radio" value="BBBB" onclick="textdisable()">
BBBB</td>
<td><input type="text" name="textfield2"></td>
</tr>
<tr>
<td> </td>
<td><input type="text" name="textfield3"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="button" name="Button" value="Go To Page2">
</div></td>
</tr>
</table>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Page1</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function textdisable() {
if(radiobutton[0].checked){textfield1.disabled=false;textfield2.disabled=true;}
else {textfield1.disabled=true;textfield2.disabled=false;}
}
</script>
</head>
<body>
<table width="240" border="1">
<tr>
<td width="67"><input name="radiobutton" type="radio" value="AAAA" onclick="textdisable()">
AAAA</td>
<td width="157"><input type="text" name="textfield1"></td>
</tr>
<tr>
<td><input name="radiobutton" type="radio" value="BBBB" onclick="textdisable()">
BBBB</td>
<td><input type="text" name="textfield2"></td>
</tr>
<tr>
<td> </td>
<td><input type="text" name="textfield3"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="button" name="Button" value="Go To Page2">
</div></td>
</tr>
</table>
</body>
</html>
解决方案 »
- 求教:如何将子(child) dropdownlist中取的值,赋给上一级 (parent)dropdownlist
- js Tab延迟切换问题
- 关于服务器登陆的问题
- 《请教这里懂得修改eWebEditor编辑器的高手,谢谢》
- appendChild的一个奇怪问题,大家来看看
- 求助一个简单问题
- javaScript和asp混合书写的问题
- jquery.validationEngine插件 用ajax验证和funcCall验证,验证不通过也提交给服务器啦
- 关于从地址中取出相应值的问题!
- DWZ框架的分页,总共多少条,共{$totalCount}条 ,统计不对
- attachEvent的问题
- 超急!!!!为什么以数字做为NAME就会出错..有何解决之道(详见内)
page2.htm<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Page2</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function textdisable(i) {
if(i==0){textfield1.disabled=false;textfield2.disabled=true;}
else {textfield1.disabled=true;textfield2.disabled=false;}
}
</script>
</head>
<body>
<table width="500" border="1">
<tr>
<td><select name="select" onchange="textdisable(this.selectedIndex)">
<option value="o" selected>Fill TextField1</option>
<option value="1">Fill TestField2</option>
</select></td>
<td><input type="text" name="textfield1"></td>
</tr>
<tr>
<td> </td>
<td><input type="text" name="textfield2"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="button" name="Button" value="Go To Page1">
</div></td>
</tr>
</table>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Page1</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function textdisable() {
if(radiobutton[0].checked){textfield1.disabled=false;textfield2.disabled=true;}
else {textfield1.disabled=true;textfield2.disabled=false;}
}
</script>
</head>
<body>
<table width="240" border="1">
<tr>
<td width="67"><input name="radiobutton" type="radio" value="AAAA" onclick="textdisable()">
AAAA</td>
<td width="157"><input type="text" name="textfield1"></td>
</tr>
<tr>
<td><input name="radiobutton" type="radio" value="BBBB" onclick="textdisable()">
BBBB</td>
<td><input type="text" name="textfield2"></td>
</tr>
<tr>
<td> </td>
<td><input type="text" name="textfield3"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="button" name="Button" value="Go To Page2" onclick="location.href='page2.htm'">
</div></td>
</tr>
</table>
</body>
</html>
page2.htm<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Page2</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function textdisable(i) {
if(i==0){textfield1.disabled=false;textfield2.disabled=true;}
else {textfield1.disabled=true;textfield2.disabled=false;}
}
</script>
</head>
<body>
<table width="500" border="1">
<tr>
<td><select name="select" onchange="textdisable(this.selectedIndex)">
<option value="o" selected>Fill TextField1</option>
<option value="1">Fill TestField2</option>
</select></td>
<td><input type="text" name="textfield1"></td>
</tr>
<tr>
<td> </td>
<td><input type="text" name="textfield2"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="button" name="Button" value="Go To Page1" onclick="location.href='page1.htm'">
</div></td>
</tr>
</table>
</body>
</html>
--------------------------------page1页面
------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Page1</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
document.onclick = function () {
if (event.srcElement.name != "radiobutton")
return;
if (event.srcElement.value == "AAAA")
{
txt1.disabled = false;
txt2.disabled = true;
txt3.disabled = true;
}
if (event.srcElement.value == "BBBB")
{
txt1.disabled = true;
txt2.disabled = false;
txt3.disabled = false;
}
};
</script>
</head>
<body>
<table width="240" border="1">
<tr>
<td width="67"><input name="radiobutton" type="radio" value="AAAA">
AAAA</td>
<td width="157"><input id=txt1 type="text" name="textfield1"></td>
</tr>
<tr>
<td><input name="radiobutton" type="radio" value="BBBB">
BBBB</td>
<td><input id=txt2 type="text" name="textfield2"></td>
</tr>
<tr>
<td> </td>
<td><input id=txt3 type="text" name="textfield3"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="button" name="Button" value="Go To Page2">
</div></td>
</tr>
</table>
</body>
</html>page2页面
-----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Page2</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function changeTxt(nIndex)
{
txt1.disabled = nIndex==0 ? false : true;
txt2.disabled = nIndex==0 ? true : false;
}window.onload = function(){
txt1.disabled = false;
txt2.disabled = true;
};
</script>
</head>
<body>
<table width="500" border="1">
<tr>
<td><select name="select" onchange="changeTxt(this.selectedIndex)">
<option value="o" selected>Fill TextField1</option>
<option value="1">Fill TestField2</option>
</select></td>
<td><input id=txt1 type="text" name="textfield1"></td>
</tr>
<tr>
<td> </td>
<td><input id=txt2 type="text" name="textfield2"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="button" name="Button" value="Go To Page1">
</div></td>
</tr>
</table>
</body>
</html>关于对页面切换的操作, 必须这两个页面(窗口)为父子关系
例如:你可以在page1中用window.open打开一个子窗口page2
在page1页面中加入
<a href=# onclick="pop()">open window</a>
<script>
var msg=window;
function pop(){
msg = window.open("page2.htm");
}
</script>page1中改一下:
<input type="button" name="Button" value="Go To Page2" onclick="msg.focus()">page2中改一下:
<input type="button" name="Button" value="Go To Page2" onclick="window.opener.focus()">
参照wanghr100
不一定非要是父子关系,我想得多了点:)