Forum Moderators: open

Message Too Old, No Replies

clear radio button - syntax problem

         

brnco

10:27 am on Oct 16, 2007 (gmt 0)

10+ Year Member



I have an application with flexible radio buttons.
The name of radio button is radiobtn + somevalue, which is defined as a number:

for example:
var somevar = 1

The problem in my function is that line of code:

document.form1.radiobtn("+somevar+")[i].checked=false;

Probably It's a syntax error but I tried all the possibilities and it still doesn't work properly.

I would be very thankful for your help.

penders

12:40 pm on Oct 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The name of radio button is radiobtn + somevalue...

I would have thought that you'd want to give all radio buttons (at least in the same group) the same name. If they don't have the same name then they won't behave as a radio group. Or have I got the wrong end of the stick? You can then access these as an array.

If all your radio buttons have the name 'radiobtn', then you can use:

document.form1.radiobtn[i].checked = false;

<edit>

Actually, thinking about it, if you do have several groups of radio buttons, then I think you should be able to do something like:

document.form1.elements["radiobtn"+somevar][i].checked = false;