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 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    <--Javascript N00b here.

    I have two radio checkboxes that each have a numeric value assigned to them.
    I want their value to appear in a text input field when one is selected.

    Anyone know how to do that?

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
    function show(check,text){
    document.getElementById(text).value+=document.getElementById(check).value;
    }
    </script>
    assign the function to the radio button on the event "onClick",the first argument is the checkbox id and the second is the textbox id.

  • #3
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks.

    Sorry to be a pain, but I can't figure out what I'm doing wrong.
    Here's what I have. I'm probably missing something obvious....


    Code:
    <html>
    <head>
    
    <script type="text/javascript">
    function show(usmail,shipping){
    document.getElementById(shipping).value+=document.getElementById(usmail).value;
    }
    
    
    
    function show(nextday,shipping){
    document.getElementById(shipping).value+=document.getElementById(nextday).value;
    }
    </script>
    
    
    </head>
    
    
    <body>
    <input type="radio" name="radio1" value=5.95 id="usmail"
    onClick="show(usmail,shipping);">
    <input type="radio" name="radio1" value=8.95 id="nextday" 
    onClick="show(usmail,shipping);">
    
    <input type="text" id="shipping">
    </body>
    
    </html>

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Code:
    <html>
    <head>
    
    <script type="text/javascript">
    function show(what,where){
    document.getElementById(where).value=document.getElementById(what).value;
    }
    </script>
    
    
    </head>
    
    
    <body>
    <input type="radio" name="radio1" value="5.95" id="usmail"
    onClick="show('usmail','shipping');">
    <input type="radio" name="radio1" value="8.95" id="nextday" 
    onClick="show('nextday','shipping');">
    <input type="text" id="shipping">
    </body>
    
    </html>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New Coder
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ohhh, haha.
    Man, I feel dumb.

    Thanks a ton!


  •  

    Posting Permissions

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