Wordpress Themes - Debt Consolidation - Web Advertising - Debt Consolidation - Sportingbet

PDA

View Full Version : need select menu to change var code in <head>


jumpajoe
Aug 20th 2007, 12:42 pm
Hello...
I have been trying to figure this out on my own but no can do....

I have a script in the <head> such as
_______________________________
function total(what,number) {
var grandTotal = 599;
for (var i=0;i<number;i++) {
if (what.elements['price' + i].value == '')
what.elements['price' + i].value = '0.00';
blahblahblah
_____________________________

I need to figure out how i can have a select drop down menu where the user can select an option which will change the grandTotal number in that code....

any ideas?
thank you.

mjamesb
Aug 20th 2007, 5:42 pm
You have the variable grandtotal scoped locally inside the function. You need to make it a global variable so it can be accessed both outside and inside the function.

<script>
var grandTotal = 0;

function total(what,number) {

for (var i=0;i<number;i++) {
if (what.elements['price' + i].value == '')
what.elements['price' + i].value = '0.00';
}
function SetGrandTotal(value)
{
grandTotal = value;
}
</script>

<body>
<select onchange="SetGrandTotal(this.value);"><option value="100">100<option value="200">200</select>
</body>