•
•
•
•
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 426,014 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 1,642 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: 522 | Replies: 2 | Solved
![]() |
•
•
Join Date: Aug 2008
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
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..
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 : Aug 5th, 2008 at 2:29 am.
•
•
Join Date: Aug 2008
Posts: 375
Reputation:
Rep Power: 1
Solved Threads: 34
That was fun ... try this, it seems to work okay
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
...
<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
...
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Arrrgggghhhh... Radio Buttons are the bain of my life! Can someone please help. (ASP)
- radio button ASP question?? (ASP)
- dynamically generated textboxes & radio buttons php, insert into db (PHP)
- I need advices for the Pseudocode (JavaScript / DHTML / AJAX)
- Need help. I am not able to get a radio button to go to the URL (PHP)
- Am not able to get a radio button selection to display in output (PHP)
- Problem passing value from radio button to second page. (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: create text field using ajax
- Next Thread: Javascript resize problem


Linear Mode