shauniqua Posted August 14, 2010 Share Posted August 14, 2010 i am working on a registration form for a school. in it, i've got a series of four selects which i'd like to use for two bits of information: <option value="675">Class Title ... $650 + $25 materials</option> where the value of the option applies to $classTuition1 through $classTuition4, and the text applies to $class1 through $class4. there's a script running, accruing a total cost from the $classTuitions: <script language="javascript"> var registrationOptionIndex = 0; function recalcReg(buttonIndex){ if ((buttonIndex == 0 ) || (buttonIndex == 1) || (buttonIndex == 2)){ registrationOptionIndex = buttonIndex } // function recalcReg(option) { // var value = value = parseInt(option.value); // } var regFee = 20; if ((buttonIndex == 0) || (registrationOptionIndex == 0)){ } else { var regSum = parseInt(document.getElementById('classTuition1').value); if (parseInt(document.getElementById('classTuition2').value) > 0) { regSum = regSum + parseInt(document.getElementById('classTuition2').value); } if (parseInt(document.getElementById('classTuition3').value) > 0) { regSum = regSum + parseInt(document.getElementById('classTuition3').value); } if (parseInt(document.getElementById('classTuition4').value) > 0) { regSum = regSum + parseInt(document.getElementById('classTuition4').value); } if ((buttonIndex == 1) || (registrationOptionIndex == 1)){ regFee = 20; } else if ((buttonIndex == 2) || (registrationOptionIndex == 2)){ regFee = 20 + (regSum / 10); } } document.getElementById('registrationFee').value = regFee; }; </script> i know i'm going about something wrong here, but after a week of poking and prodding, i cannot find the solution. surely there is a way to generate 4 iterations of this <select>, each grabbing the value and text? any help is greatly appreciated. (attached php file is a wordpress template file with the reg.form inside) [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
jl5501 Posted August 14, 2010 Share Posted August 14, 2010 Your main problem seems to be here you have onChange="recalcReg(this.options[this.selectedValue]) you should have onChange="recalcReg(this.options[this.selectedIndex].value) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.