Forum Moderators: open
I manage to do this using this:
<form>
<input type="text" name="txtTarget" value=2>
<SELECT size="5" onchange="this.form.txtTarget.value=parseInt(this.form.txtTarget.value) + parseInt(this.options[this.selectedIndex].value);">
<option value=5>Blue (add $5)</option>
<option value=10>Red (add $10)</option>
</SELECT>
</form>
But, when I change it to another option, it keeps adding the total, I need it to go back to the original value and add the new option selected.
Another thing I need is another value (ID) called from a DB to be carried over to the next page, so if the user selected "Blue (add $5)" that option's ID from the DB must be carried over... I hope I made this clear enough.
Please someone - I'm very new to this and need help... thanks
Jacques
I need help, urgently!
don't we all ;)
how about
onchange="this.form.txtTarget.value=2 + parseInt(this.options[this.selectedIndex].value);"
don't know if you need to leave the parseInt in there, I wouldn't think so but you can try it.
As far as passing values goes, I have never done it with javascript only server side scripting languages so someone else may have the answer for that.
You can pass a variable from one page to another using JavaScript by adding the variable to the URL. This can be done on the form, my using method="link":
<FORM METHOD="LINK" ACTION="receivingPage.html">
This will add the variables from your form to the URL:
www.domain.com/receivingPage.html?firstName=Jane&surName=Doe
You can then use some JavaScript on the receiving page to strip out the variables from the url.
HTH