我用ajax在拿到请求的页面的返回值之后做这样的的操作
document.getElementById("RadioButton1").checked=true;
页面上的RadioButton 没有处于选择状态,但是我这样的写:
document.getElementById("RadioButton1").checked=true;
alert("sucess");
然后把这个对话框点了,页面上的RadioButton 就处于选中状态了。这是什么原因?然后我有做这样的一个Demo<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function aa() {
document.getElementById("Man").checked = !document.getElementById("Man").checked;
document.getElementById("Woman").checked = !document.getElementById("Woman").checked;
}
</script>
</head>
<body onLoad="setInterval('aa()',500)">
<form id="form1" runat="server">
<div>
<input type="radio" title="Man" id="Man" name="Man" checked="checked"/>Man
<input type="radio" title="Woman" id="Woman" name="Woman"/>Woman
</div>
</form>
</body>
</html> 这样就可以改变RadioButton 的状态了。为什么?
document.getElementById("RadioButton1").checked=true;
页面上的RadioButton 没有处于选择状态,但是我这样的写:
document.getElementById("RadioButton1").checked=true;
alert("sucess");
然后把这个对话框点了,页面上的RadioButton 就处于选中状态了。这是什么原因?然后我有做这样的一个Demo<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function aa() {
document.getElementById("Man").checked = !document.getElementById("Man").checked;
document.getElementById("Woman").checked = !document.getElementById("Woman").checked;
}
</script>
</head>
<body onLoad="setInterval('aa()',500)">
<form id="form1" runat="server">
<div>
<input type="radio" title="Man" id="Man" name="Man" checked="checked"/>Man
<input type="radio" title="Woman" id="Woman" name="Woman"/>Woman
</div>
</form>
</body>
</html> 这样就可以改变RadioButton 的状态了。为什么?
试试
例:
document.getElementById('aaa').checked = 'checked'
<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">
window.onload=function()
{
document.getElementById("RadioButton1").checked=true;
}
</script>
<body>
<input type="radio" title="Man" id="RadioButton1" name="Man"/>
</body>
</html>上面的代码没发现什么问题可能是加载循序什么的其他问题导致的
我们实施了exchange,用户在用owa访问exchange时候有两个 RadioButton ,让用户选择是当前计算机是公用计算机或是私人计算机,用户想这样的天天这样选很麻烦,我就修该了exchange中的js文件,把用户提交表单的jscode 放在了我的ajax的 的回调函数中,这个ajax是向一个页面请求判断当前计算机是不是私人计算机,然后再提交表单,表单会把这个信息提交到exchange服务器的。剩下的我们就不管了。
我就是那样做的,但是在用
alert("111");
document.getElementById("RadioButton1").checked=true;
上面的RadioButton 就可以改变选中状态,如果我没有写alert(“1111”)就不行?
不知道是什么原因。