简体   繁体   English

Javascript如何掩盖单选按钮是否被选中?

[英]How can Javascript mask whether radio button is checked?

Is it possible with Javascript to hide the checked-status of a radio button so that on a form submit the submit-request fails b/c of missing information? 用Javascript是否可以隐藏单选按钮的检查状态,以便在表单提交中提交请求失败而丢失信息?

For example: I have a group of radio buttons 例如:我有一组单选按钮

<form action="?modul=daDaaaah&subModul=someCoolThingy" method="post">
    <input type="radio" name="mygroup" id="nod_1" value="great" />
    <input type="radio" name="mygroup" id="nod_2" value="greater" />
    <input type="radio" name="mygroup" id="nod_3" value="awesome" />
    <input type="radio" name="mygroup" id="nod_4" value="junk" />
    <input type="radio" name="mygroup" id="nod_5" value="foo" />
    <input type="submit" name="edit" value="Edit" />
</form>

Now I am checking the radio button with the id=1 and by submitting it (dunno whether I got the button correct, but I sorta guess it is correct) the server should get a request where it says mygroup=great (right?). 现在,我正在检查id=1的单选按钮并提交(不知道我的按钮是否正确,但我猜它是正确的),服务器应该在mygroup=great (正确吗?)的地方收到一个请求。

Now is there a way to have that radio button checked and hidden it at the same time? 现在有一种方法可以同时检查并隐藏该单选按钮吗?

I am asking b/c somehow a javascript I am using is supposedly hiding this status (everywhere but in IE) by somehow altering the DOM or what do I know and I can't seem to get the right request nor find the reason why or how it does it. 我以某种方式问b / c我正在使用的javascript应该通过某种方式更改DOM或我所知道的内容来隐藏此状态(无论在IE中还是其他地方),我似乎无法收到正确的请求,也找不到原因或它是如何做到的。

If I am being unclear, please say so. 如果我不清楚,请这样说。

EDIT: One javascript that has this effect can be found here http://www.frequency-decoder.com/demo/table-sort-revisited/js/paginate.js but others do so as well :( 编辑:一种具有这种效果的javascript可以在这里找到http://www.frequency-decoder.com/demo/table-sort-revisited/js/paginate.js,但是其他的也可以做到这一点:(

EDIT: Changed ID-names. 编辑:更改ID名称。 Still doesn't work. 仍然不起作用。

One thing is you can not have ids that begin with a number. 一件事是您不能使用以数字开头的ID。 So your radio buttons should be something like rad1, rad2, etc. 因此,您的单选按钮应类似于rad1,rad2等。

如果无线电已禁用=“ true”,那么该值将不会出现在请求中,因此您可以进行检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM