logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 03-25-2008, 03:24 AM   #1
mangofreak
mangofreak's Avatar
 
Join Date: Jan 2006
Location: Toronto-Canada
Posts: 444
Default trying to ADD menu items

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.
__________________
J.
DW | FW | HTML | CSS | ASP | some PHP | Windows | Ubuntu
mangofreak is offline   Reply With Quote
Old 03-25-2008, 10:28 PM   #2
student101
 
Join Date: Dec 2007
Posts: 379
Smile

Enjoy...

Code:
<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
__________________
Amateurs ... Built the ark.
Professionals ... Built the Titanic.
specificity [sound like spe-sifis-ity]

Last edited by student101; 03-25-2008 at 10:39 PM..
student101 is offline   Reply With Quote
Old 03-27-2008, 04:08 AM   #3
mangofreak
mangofreak's Avatar
 
Join Date: Jan 2006
Location: Toronto-Canada
Posts: 444
Default

thanks Student101, for the response and the info. I'll play with it and see what mess I get into. Cheers.
__________________
J.
DW | FW | HTML | CSS | ASP | some PHP | Windows | Ubuntu
mangofreak is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com