I'm such a noob

Results 1 to 2 of 2

Thread: I'm such a noob

  1. #1
    Join Date
    Dec 1969

    Default I'm such a noob

    I suck at Javascript, but can someone tell me how to do this:<BR><BR>I have a certain amount of radio tags generated by an ASP page. The radio tags are all named "id"<BR><BR>each of them have a different value, the value is obtained from a DB IDENTITY column.<BR><BR>How would I write a javascript to tell me the value of the radio button that is is selected?

  2. #2
    Join Date
    Dec 1969

    Default Been asked many times...

    ...so obviously you aren&#039;t alone.<BR><BR>&#060;SCRIPT Language="JavaScript"&#062;<BR><BR>function getRadioGroupValue( group )<BR>{<BR> // if this isn&#039;t *really* a group, don&#039;t treat it as one<BR> if ( ! group.length ) return ( group.checked ? group.value : null );<BR><BR> // *is* a group, so loop<BR> for ( var rbnum = 0; rbnum &#060; group.length; ++rbnum )<BR> {<BR> var rb = group[rbnum]; // one radio button<BR> if ( rb.checked ) return rb.value;<BR> }<BR> return null; // none checked<BR>}<BR><BR>// to invoke that:<BR><BR>var idValue = getRadioGroupValue( document.YourFormName.id );<BR>...<BR><BR>&#060;/SCRIPT&#062;<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts