Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: functions


Message #1 by "Pham, Khanh" <Khanh.Pham@d...> on Tue, 19 Nov 2002 15:03:33 -0500
Can someone tell me what is wrong with this code.  I am validating sections
of radio buttons.  I create a function called "radioCheck(x,z)" and a
function called "Validate()".  It just calls radioCheck once from validate
and submits the form.

Thanks all.
*********************************************************************
<script language="JavaScript">
function Validate(pham){
	return radioCheck("rQ1","1");
	return radioCheck("rQ2","2");
	return radioCheck("rQ3","3");
	return radioCheck("rQ4","4");
	return radioCheck("rQ5","5");
	return radioCheck("rQ6","6");
}
function radioCheck(x,z){
	useroption = -1
	for(i=0; i<eval("document.frmSurvey."+x+".length"); i++){
		if (eval("document.frmSurvey."+x+"[i].checked")){
			useroption = i; 			
			break;
			return false
		}
	}
	if(useroption == -1){
		alert("Please answer Question "+z+".")
		eval("document.frmSurvey."+x+"[0].focus();")
		return false;
	}

}
</script>
*************************************************************8

  Return to Index