www.webdeveloper.com
Results 1 to 4 of 4

Thread: Radio Forms

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Posts
    5

    Radio Forms

    First off, I am sorry...new to java and new to the forum.

    But I am trying to write a radio button form that has dynamic output.

    If radio 1 selected then the text would say "one", if radio 2 text = "two", etc

    for example :

    How many chickens do you own?
    Radio 1
    Radio 2
    *Radio 3
    Radio 4

    I own three chickens.

    I have the following and am stuck, can I stack getElementsbyid...?

    Code:
    <script type="text/javascript">
    function check() {
       document.getElementById('Radio1').firstChild.nodeValue='one';
     }
    
    <form>
    <input type="radio" value="0" id="r1" name="r1" onclick="check()" />
    <input type="radio" ???? />
    <input type="radio" ???? />
    <input type="radio" ???? />
    </form>
    
    I own <label for="r1" id="Radio1">blank</label> chickens.

    any help would be greatly appreciated

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    <script type="text/javascript">
    function check(x) {
    document.getElementById('Radio1').innerHTML = x;
    }

    <form>
    <input type="radio" value="one" id="r1" name="r1" onclick="check(this.value);" />
    <input type="radio" value="two" id="r1" name="r1" onclick="check(this.value);" />
    <input type="radio" value="three" id="r1" name="r1" onclick="check(this.value);" />
    <input type="radio" value="four" id="r1" name="r1" onclick="check(this.value);" />
    </form>
    I own <label for="r1" id="Radio1">blank</label> chickens.

  3. #3
    Join Date
    Jan 2011
    Posts
    5

    That did it

    It worked

    This is one of the better forums Im going to spam this thread with 'thanks'


    not really...but thank you very much.

  4. #4
    Join Date
    Jan 2011
    Posts
    5

    That did it

    Quote Originally Posted by WolfShade View Post
    <script type="text/javascript">
    function check(x) {
    document.getElementById('Radio1').innerHTML = x;
    }

    <form>
    <input type="radio" value="one" id="r1" name="r1" onclick="check(this.value);" />
    <input type="radio" value="two" id="r1" name="r1" onclick="check(this.value);" />
    <input type="radio" value="three" id="r1" name="r1" onclick="check(this.value);" />
    <input type="radio" value="four" id="r1" name="r1" onclick="check(this.value);" />
    </form>
    I own <label for="r1" id="Radio1">blank</label> chickens.
    Thank you soo much worked like a charm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles