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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.