HighDots Forums  

Re: check if radio is checked

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: check if radio is checked in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Anthony Levensalor
 
Posts: n/a

Default Re: check if radio is checked - 01-03-2008 , 09:35 AM






Randy Webb said:

[snip]
Quote:
IE might let you get away with that but IE doesn't have a clue what
the difference between an ID and a NAME is.
Firefox lets you get away with it, and so does Safari on Win. They
treat it kjust like any other element with an ID. I've seen a lot of
people "work around" radios this way, although I'm not a huge fan of
it, it can definitely be done across the majors.

They substitute the ID for a NAME attribute when using the forms
collection?

No, sorry, misread his code. I thought you were saying they didn't allow
access via ID, and was confused.




Reply With Quote
  #12  
Old   
Anthony Levensalor
 
Posts: n/a

Default Re: check if radio is checked - 01-03-2008 , 09:37 AM






Matt Kruse said:

[snip]
Quote:
The worst I've had to deal with is working with a form that had
different types of inputs, all with the same name but with uniquely-
identifying values. That is hell.

I think this one wins the PITA award, Randy.

~A!



Reply With Quote
  #13  
Old   
Randy Webb
 
Posts: n/a

Default Re: check if radio is checked - 01-03-2008 , 11:56 AM



Anthony Levensalor said the following on 1/3/2008 10:37 AM:
Quote:
Matt Kruse said:

[snip]
The worst I've had to deal with is working with a form that had
different types of inputs, all with the same name but with uniquely-
identifying values. That is hell.

I think this one wins the PITA award, Randy.
I have seen benefits to Radio Buttons, never seen a benefit to the
scenario Matt is describing. I don't even use the benefits of name[]
that PHP brings to you. Although just the prospects of it sounds like hell.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Reply With Quote
  #14  
Old   
Anthony Levensalor
 
Posts: n/a

Default Re: check if radio is checked - 01-03-2008 , 01:58 PM



Randy Webb said:

[snip]
Quote:
I have seen benefits to Radio Buttons, never seen a benefit to the
scenario Matt is describing. I don't even use the benefits of name[]
that PHP brings to you. Although just the prospects of it sounds like hell.


See, and I'll use the first level of that in PHP, with simple arrays, or
running a couple in parallel. But when it comes time to start running
multiple subscripts/dimensions, I'm all set, no thanks.

--
anthony at my pet programmer dot com


Reply With Quote
  #15  
Old   
David Mark
 
Posts: n/a

Default Re: check if radio is checked - 01-04-2008 , 03:15 AM



On Jan 3, 3:59*am, "Evertjan." <exjxw.hannivo... (AT) interxnl (DOT) net> wrote:
Quote:
David Mark wrote on 03 jan 2008 in comp.lang.javascript:

INPUT TYPE=RADIO NAME=Q VALUE=1 ID=Q1
INPUT TYPE=RADIO NAME=Q VALUE=2 ID=Q2
allowing the use of something like: document.form.Q1.checked.

If it were this simple, then even I could manage it.

You can do that.

But you wouldn't want to. *Assuming a form with name "formName", the
two elements' checked values should be referenced as:

document.forms.formName.elements.Q[0].checked
document.forms.formName.elements.Q[1].checked

But only if the input/radios are/stay in the right order!
Not really.

Quote:
If you, a year later, change the code to to

INPUT TYPE=RADIO NAME=Q VALUE=2 ID=Q2> water<br
INPUT TYPE=RADIO NAME=Q VALUE=1 ID=Q1> fire<br

you could have a hell of debugging.
Only one can be checked and the value of that checked element is all
that matters. For that reason, it doesn't make sense to reference a
specific radio button by ID. Granted, the OP seems to indicate a
desire to do so.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.