在javascript中重置radiobuttonlist [英] reset radiobuttonlist in javascript
问题描述
如何在javascript中重置radiobuttonlist
i需要在点击超链接时重置radiobuttonlist
i已将代码写为
document.getElementById(''rblOffshoreFamiliarity'')。 selectedIndex = 0;
document.getElementById(''rblOffshoreFamiliarity'')。 value = 1;
document.getElementById(''rblOffshoreFamiliarity'')。 value = options [-1];
这一切都不起作用
你可以帮我解决这个问题
您是否只想重置单选按钮或表单上的所有内容?如果您不介意重置所有内容,只需使用表单的'resetquote>。嗨......
如果您只想重置无线电,请查看以下示例:
[HTML]< html>
< head>
< script>
function reset_radio_grp(){
var rgrp = document.getElementsByName(''rblOffshoreFamiliarity'');
rgrp [0] .checked =''checked'';
}
< / script>
< / head>
< body>
< form name =" my_form">
< input type =" radio"名称= QUOT; rblOffshoreFamiliarity"值= QUOT 1 QUOT; checked =" checked" />
< input type =" radio"名称= QUOT; rblOffshoreFamiliarity" value =" 2" />
< input type =" radio"名称= QUOT; rblOffshoreFamiliarity" value =" 3" />
< input type =" button" value =" reset radio group" onclick =" reset_radio_grp();" />
< / form>
< / body>
< / html>
[/ HTML]
亲切的问候
嗨...
如果您只想重置无线电,请查看以下示例:
是,我想我不妨先采用简单的方法。
然而,通常不会选中一组单选按钮?
how do i reset radiobuttonlist in javascript
i need to reset radiobuttonlist on click of a hyperlink
i have written the code as
document.getElementById(''rblOffshoreFamiliarity''). selectedIndex=0;
document.getElementById(''rblOffshoreFamiliarity''). value=1;
document.getElementById(''rblOffshoreFamiliarity''). value=options[-1];
none of this is working
can u guyz help me out with this解决方案Do you only want to reset the radio buttons or everything on the form? If you don''t mind resetting everything, just use the form''s reset() method.
hi ...
in case you want only the radios resetted have a look at the following example:
[HTML]<html>
<head>
<script>
function reset_radio_grp() {
var rgrp = document.getElementsByName(''rblOffshoreFamiliarity '');
rgrp[0].checked = ''checked'';
}
</script>
</head>
<body>
<form name="my_form">
<input type="radio" name="rblOffshoreFamiliarity" value="1" checked="checked"/>
<input type="radio" name="rblOffshoreFamiliarity" value="2"/>
<input type="radio" name="rblOffshoreFamiliarity" value="3"/>
<input type="button" value="reset radio group" onclick="reset_radio_grp();"/>
</form>
</body>
</html>
[/HTML]
kind regards
hi ...
in case you want only the radios resetted have a look at the following example:Yes, I thought I might as well take the simple approach first.
However, isn''t a set of radio buttons normally unchecked?
这篇关于在javascript中重置radiobuttonlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!