newscript

Mar 5th, 2011, 03:47 AM

Hi all,

I have created two sets of radio buttons. One for the tour type, the other for the discount type.

I want to get the value from the tour function and put it into the discount formula in the payment function. I tried to write the code for the discount formula in the payment function but it does not work.

Thanks in advance.:confused:

Partial codes are as follows:

function selectedTourTypeCost()

{

var radioButtonTour; //A tour type radio button.

var costTour = 0; //Cost of the selected tour type.

//Get the number of the selected tour (1,2,3 or 4)

for (var i = 1; i <= 4; i++)

{

radioButtonTour = document.getElementById("tour" + i);

if (radioButtonTour.checked == true)

{

costTour = parseInt(radioButtonTour.value);

}//end if loop

}//end for loop of selected tour

return costTour;

}//end function SelectedTourTypeCost()

function selectedPaymentType()

{

var radioButtonPayment;//A payment type radio button

var selectedPayment = 0; //The number of the selected payment.

//Get the number of the selected payment (1,2,3 or 4)

for (var i = 1; i <= 4; i++)

{

radioButtonPayment = document.getElementById("payment" + i);

if (radioButtonPayment.checked == true)

{

selectedPayment = i;

}//end if loop for getting the selected payment number

}//end for loop for getting the selected payment type

//Calculate the appropriate response

if (selectedPayment == 1)

{

var discount = 0;

discount = (10/100) * selectedTourTypeCost();

}

alert ("Discount:" + discount);

}//end selectedPaymentType() function

</script>

</head>

I have created two sets of radio buttons. One for the tour type, the other for the discount type.

I want to get the value from the tour function and put it into the discount formula in the payment function. I tried to write the code for the discount formula in the payment function but it does not work.

Thanks in advance.:confused:

Partial codes are as follows:

function selectedTourTypeCost()

{

var radioButtonTour; //A tour type radio button.

var costTour = 0; //Cost of the selected tour type.

//Get the number of the selected tour (1,2,3 or 4)

for (var i = 1; i <= 4; i++)

{

radioButtonTour = document.getElementById("tour" + i);

if (radioButtonTour.checked == true)

{

costTour = parseInt(radioButtonTour.value);

}//end if loop

}//end for loop of selected tour

return costTour;

}//end function SelectedTourTypeCost()

function selectedPaymentType()

{

var radioButtonPayment;//A payment type radio button

var selectedPayment = 0; //The number of the selected payment.

//Get the number of the selected payment (1,2,3 or 4)

for (var i = 1; i <= 4; i++)

{

radioButtonPayment = document.getElementById("payment" + i);

if (radioButtonPayment.checked == true)

{

selectedPayment = i;

}//end if loop for getting the selected payment number

}//end for loop for getting the selected payment type

//Calculate the appropriate response

if (selectedPayment == 1)

{

var discount = 0;

discount = (10/100) * selectedTourTypeCost();

}

alert ("Discount:" + discount);

}//end selectedPaymentType() function

</script>

</head>