Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable for radio buttons?

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
EU
Hi

I am calling this function with chkQ("document.responses.q1") and my form has a set of radio buttons named q1. The for loop runs the correct number of times but the var rad_val is always undefined?
Code:
function chkQ (id) {
	for (var i=0; i < id.length; i++)
	   {
		   
	   if (id[i].checked)
		  {
		  var rad_val = id[i].value;
		  }
	   }
	alert("Q1 value = " + rad_val);
}

Anyone able to spot what I have got wrong?

Cheech

[Peace][Pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top