Jump to content

retrieving form option value and option text


shauniqua

Recommended Posts

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.