Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Location
    New Hampshire
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading the Radio Button Label

    Hello, I am new to JS and have a question which I cannot seem to find an answer. I want to read the text label assigned to a radio button (not the value and not the name), and I have not been able to find a way to do it. All of the sources I have referenced say the text label is not part of the radio button, but do not give you a way to retrieve it from a form.

    Here is an example of the assignment statement I am using for the radio button creation:

    <input TYPE="radio" NAME="support_requested_by" VALUE="PPE">Pre Production Engineering

    What I need is to be able to get the "Pre Production Engineering" text and assign it to a variable. Is this possible?

    Thanks!

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here are a couple of ways:
    Code:
    <input TYPE="radio" VALUE="PPE" onclick="alert(document.getElementById(this.value).innerHTML"><label id="PPE">Pre Production Engineering</label>
    Code:
    <span><input TYPE="radio" onclick="alert(parentNode.getElementsByTagName('LABEL')[0].innerHTML)"><label>Pre Production Engineering</label></span>

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Location
    New Hampshire
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clarification on Original Post

    What I should have probably put in the original post is that I am creating a printer friendly document from an existing HTML page and need to read the form to get the labels (not the values or names) for the radio buttons and check boxes. Is there a way to do this?

  • #4
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, no, not intrinsically. You have to code it.
    Do my examples not give you the "text label assigned to a radio button (not the value and not the name)" ?

  • #5
    New to the CF scene
    Join Date
    Jun 2004
    Location
    New Hampshire
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not exactly. What I get is a pop-up window with the words "Pre Production Engineer" as the text in the pop-up.

  • #6
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unless I'm misunderstanding your definition of a text label, the words "Pre Production Engineer" are just that.
    The alert (pop-up window) was just a way of displaying that text, for demonstration.


  •  

    Posting Permissions

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