| Author |
how to print a default selected radio button value if there is a single radio button ?
|
shivamahesh bachu
Greenhorn
Joined: Sep 14, 2012
Posts: 13
|
|
Here is My Code:-
please help me out in this
I am unable to get the output here
<html>
<head>
<script type="text/javascript">
function get_radio_value()
{
for (var i=0; i < document.orderform.music.length; i++)
{
if (document.orderform.music[i].checked)
{
var rad_val = document.orderform.music[i].value;
alert("hai"+rad_val);
}
}
}
</script>
<form name="orderform">
Which one is your favorite?<br>
<input type="radio" name="music" value="Rock" checked="checked"> Rock<br>
<input type="submit" onclick="get_radio_value()">
</form>
</body>
</head>
</html>
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
When you post code, please you code tags.
Answer can be found on this old post: http://www.coderanch.com/t/115796/HTML-CSS-JavaScript/inconsistency-radiobutton
Eric
|
 |
 |
|
|
subject: how to print a default selected radio button value if there is a single radio button ?
|
|
|