在javascript中重置radiobuttonlist [英] reset radiobuttonlist in javascript

查看:80
本文介绍了在javascript中重置radiobuttonlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆