User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,571 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,780 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 332 | Replies: 2 | Solved
Reply
Join Date: Aug 2008
Posts: 19
Reputation: Scooby08 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Scooby08 Scooby08 is offline Offline
Newbie Poster

Radio input value

  #1  
15 Days Ago
Would anybody happen to know if it's possible to hide the value of a radio button unless it is checked, and then when it is checked display that value, and then after moving on, that value stays active, and the user can fill out the rest of the form and pass that value on with php when finished??

It's part of an invoice form and each input has a dollar amount value.. Just trying to make it so the choice they chose displays how much it costs throughout the form..
Last edited by Scooby08 : 15 Days Ago at 2:29 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2008
Posts: 236
Reputation: langsor is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 20
langsor langsor is offline Offline
Posting Whiz in Training

Re: Radio input value

  #2  
14 Days Ago
That was fun ... try this, it seems to work okay

<html>
</head>
<style type="text/css">
.hide {
  display: none;
}
</style>
<script type="text/javascript">
window.onload = function () {
  var myform = document.getElementById('myform');
  myform.onclick = function () {
    for ( var i = 0; i < myform.length; i ++ ) {
      if ( myform[i].getAttribute('name') == 'price' ) {
        var ref = myform[i].getAttribute('value');
        if ( myform[i].checked ) {
          document.getElementById(ref).style.display = 'inline';
        } else {
          document.getElementById(ref).style.display = 'none';
        }
      }
    }
  };
};
</script>
</head>
<body>
<form id="myform">
  <label for="w1">Widget One</label>
  <input id="w1" value="w1h" type="radio" name="price" />
  <span id="w1h" class="hide">$9.45</span>
  <br />
  <label for="w2">Widget Two</label>
  <input id="w2" value="w2h" type="radio" name="price" />
  <span id="w2h" class="hide">$12.95</span>
</form>
</body>
</html>

Hope it helps

P.S. I keep forgetting that IE doesn't like to capture 'onchange' events for elements of a form when the handler is placed on the form element itself ... geek trivia

...
Reply With Quote  
Join Date: Aug 2008
Posts: 19
Reputation: Scooby08 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Scooby08 Scooby08 is offline Offline
Newbie Poster

Re: Radio input value

  #3  
14 Days Ago
Awesome! Thankyou!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 10:22 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC