EvilBernd
10-17-2002, 09:07 PM
Hi there
I just wanted to build a little shop based on PHP and JS, but i got totally messed up with the JS part.
I got multiple drop-downs, which should onChange display there value in a text-field. That wasn't that hard, because I only had to use this little thing:
onChange="document.form.ddownX.value=document.form.textfdX.value" in my <a>-tag. The x is a variable which is determined by PHP.
But now I wanted to create another textfield to show the total-sum of all the other text-fields and changes the textfields if the dropdown-menu is changed, but I don't get it. I tried to use a function called calc(x) which looks like this (by now):
function calc(x){
var ddown=ddown.x
var textfd=textfd.x
document.form.ddown.value=document.form.textfd.value; //change the textfield
}
As you can see its just the code to change the textfields, but even this doesn't work.
So what it wrong in there and how is it possible to calculate the sum and display it in an extra textfield??
Thx a lot EB
I just wanted to build a little shop based on PHP and JS, but i got totally messed up with the JS part.
I got multiple drop-downs, which should onChange display there value in a text-field. That wasn't that hard, because I only had to use this little thing:
onChange="document.form.ddownX.value=document.form.textfdX.value" in my <a>-tag. The x is a variable which is determined by PHP.
But now I wanted to create another textfield to show the total-sum of all the other text-fields and changes the textfields if the dropdown-menu is changed, but I don't get it. I tried to use a function called calc(x) which looks like this (by now):
function calc(x){
var ddown=ddown.x
var textfd=textfd.x
document.form.ddown.value=document.form.textfd.value; //change the textfield
}
As you can see its just the code to change the textfields, but even this doesn't work.
So what it wrong in there and how is it possible to calculate the sum and display it in an extra textfield??
Thx a lot EB