PDA

View Full Version : trying to ADD menu items


mangofreak
03-25-2008, 02:24 AM
OK. This should be a piece of cake for someone with jscript code know how. I feel like banging my head for not learning the damn script way back when. I absolutely hate it.

Here is my problem: I have a form with a select menu with values like:
1 , 2 p and 3.

When a user selects 1, then the jvascript would write, beside the select menu, the price assigned to 1 say $10
if selection is 2 then it show write $20

basically it is an addition depending on the menu selection. If someone can help me with that would be fantastic. I could do that on ASP but I need to show the addition as soon as the selection happens and with ASP I would have to run it through the server first.

Any help will be very much appreciated.

student101
03-25-2008, 09:28 PM
Enjoy...


<script>
function addOption(x,x2) {
sOption=document.getElementById(x2).value;
sOptions=sOption.split("\n");
if (sOption == '') {document.getElementById(x2).value=x+"\n";}
else {
if (sOptions.length > 1) {document.getElementById(x2).value=sOption+x+"\n";}
else {document.getElementById(x2).value=sOption+"\n"+x+"\n";}
}
document.getElementById(x2).focus();
}
</script>
<select name=selectBox1 id=selectBox1 onchange=addOption(value,'textBox1');>
<option value=0></option>
<option value='$20'>1</option>
<option value='$40'>2</option>
<option value='$60'>3</option>
</select>
<textarea rows=5 cols=25 name=textBox1 id=textBox1>
</textarea>
<br>
<br>
<select name=selectBox1 id=selectBox1 onchange=addOption(value,'textBox2');>
<option value=0></option>
<option value='$20'>1</option>
<option value='$40'>2</option>
<option value='$60'>3</option>
</select>
<textarea rows=5 cols=25 name=textBox1 id=textBox2>
</textarea>
Please note:
I googled, other than that (I have no clue) good luck.
Oh yes, best you check out this dynamic dropdowns, http://www.tecnorama.org/index.php
Cheers

mangofreak
03-27-2008, 03:08 AM
thanks Student101, for the response and the info. I'll play with it and see what mess I get into. Cheers.