I have a very simple requirement to display a price to the user based on selection of a sponsorship level as follows:
Software: $2500
Gold: $1000
Silver: $500
I believe I need to create a JS that hides a form element until a sponsorship level is selected, then determine and display the amount. I can figure out the JS for this, the question is how do I output the value to the element on the form?
Software: $2500
Gold: $1000
Silver: $500
I believe I need to create a JS that hides a form element until a sponsorship level is selected, then determine and display the amount. I can figure out the JS for this, the question is how do I output the value to the element on the form?
I finally got this to work, albeit not the cleanest code. For some reason I could not get the switch statement to work for the three cases.
window.addEvent('domready', function() {
var sponsorship_amount;
$('level').addEvent('change', function() {
if ($('level').value == 'Software') {
sponsorship_amount = 2500;
} else if ($('level').value == 'Gold') {
sponsorship_amount = 1000;
} else if ($('level').value == 'Silver') {
sponsorship_amount = 500;
} else {
sponsorship_amount = "";
}
$('total_amount').innerHTML = sponsorship_amount;
});
});
This topic is locked and no more replies can be posted.