I have two JS functions on a form. First function is "function checkData", to validate the form info, Second is "function setAction(frm)" to determin what action to take based on a radio button selection. I can't seem to get the form to run through the validation first, then run the action function based on a radio button selection.
Code Function One:
Code Function Two:Code:<script><!-- function checkData() { var text = "Enrollment Error:" var correct = true if (document.Rebate.code.value != '800') {correct = false; text += "\nThe application code you entered is incorrect"} if (document.Rebate.name.value == "") {correct = false; text += "\nPlease enter your name"} if (document.Rebate.address.value == "") {correct = false; text += "\nPlease enter your address"} if (document.Rebate.city.value == "") {correct = false; text += "\nPlease enter your city"} if (document.Rebate.state.value == "") {correct = false; text += "\nPlease enter your statecode"} if (document.Rebate.zip.value == "") {correct = false; text += "\nPlease enter your zip code"} if (document.Rebate.area.value == "") {correct = false; text += "\nPlease enter your area code"} if (document.Rebate.phone.value == "") {correct = false; text += "\nPlease enter your phone number"} if (document.Rebate.interest.value == "") {correct = false; text += "\nPlease enter your location of interest"} else if (correct == setAction(frm)) else {alert(text)} } //--> </script>
Code:<script type="text/javascript"> function setAction(frm){ act = ''; for(x=0;x<frm.interest.length;x++){ if(frm.interest[x].checked){ act = frm.interest[x].value; } } if(act == 'flagler'){ frm.action = 'rebate_enrollment_action_flagler.asp'; } else if(act == 'nbrevard'){ frm.action = 'rebate_enrollment_action_nbrevard.asp'; } else if(act == 'cbrevard'){ frm.action = 'rebate_enrollment_action_cbrevard.asp'; } else if(act == 'sbrevard'){ frm.action = 'rebate_enrollment_action_sbrevard.asp'; } else if(act == 'indianriver'){ frm.action = 'rebate_enrollment_action_indianriver.asp'; } else{ alert('Please choose an option'); return false; } } </script>Code:<form name="form1" method="post" action="" onSubmit="return checkData()">


Reply With Quote


Bookmarks