Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to print a default selected radio button value if there is a single radio button ?

 
shivamahesh bachu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic