View Full Version : forms calculating cost for a product selection

09-20-2005, 10:58 AM
Hey guys i have the following validated html strict code and i wish make a function in java script that allows the user to click on an option value such as
"Gibson Flying V" then display its cost in the cost option list.

for example

product selection (Gibson Flying V)

Cost (400)

the cost should automatically change to whatever the user selects in terms of the product any idea's anyone.

<SELECT NAME="mylist">
<OPTION VALUE="m1">Canora Stratocaster

<OPTION VALUE="m2">Fender Stratocaster
<OPTION VALUE="m3">Guild Electric
<OPTION VALUE="m4">Gibson Flying V
<OPTION VALUE="m5">Monterey
<tr> <td align="left">Cost</td> <td align="left"><SELECT NAME="mylist">
<OPTION VALUE="m1">$500.00
<OPTION VALUE="m2">$1000.00
<OPTION VALUE="m3">$200.00
<OPTION VALUE="m4">$400.00
<OPTION VALUE="m5">$3000.00
<tr> <td align="left">Are there anymore items</td>

<td align="left"><input type="checkbox" value="Age" size="20">Yes/No</td></tr>
<tr> <td align="left">Method of Payment</td>
<td align="left"><input type="radio" value="Cash" name="pay" size="20">
Credit<input type="radio" value="Credit" name="pay"size="20">
Cheque<input type="radio" value="Direct Debit" name="pay"

09-20-2005, 11:16 AM
If the order of option items correspond to the same order in another, then you can simply do this:

<select name="mylist" onchange="this.form.mycost.selectedIndex=this.selectedIndex;">
<select name="mycost">

09-20-2005, 11:34 AM
Do also know a way i can apply it to a text field? Iv tried

<input type = "text" name = "cost" id = "cost of product">