Click to See Complete Forum and Search --> : link a price to a pulldown menu


olivetomato
09-05-2003, 04:16 AM
Hi all,

I am working on an order form in which the customer can calculate the total price before he finalizes the order.

I have done this before where the product was a fixed value (thus the price is too)

However now customers can choose from a pulldown menu which product they can order (thus the price varies)

I am using two arrays: one with the product name and one with the price

Any help, suggestions and/or smart ass remarks :D are welcome!!

Thanks!!!!
Erik

Fang
09-05-2003, 05:39 AM
Get the value from the selected option
<option value="10.50">product X</option>

olivetomato
09-05-2003, 06:20 AM
errrr...........how?

(yes I'm a total newbie :confused: ..)

Fang
09-05-2003, 09:53 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Pulldown select</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

<script type="text/javascript">
//<![CDATA[
<!--
function Cost(obj) {
var selection="You chose: \n";
var total=0;
for(var i=0; i<obj.list.options.length; i++) {
if(obj.list.options[i].selected) {
selection+=obj.list.options[i].text+" @ "+parseFloat(obj.list.options[i].value)+"\n";
total+=parseFloat(obj.list.options[i].value);
}
}
alert(selection+"\ncosting: $ "+total);

}
//-->
//]]>
</script>

</head>
<body>
<form action="#" name="products" onsubmit="Cost(this); return true;">
<p>Press Ctrl key to select multiple</p>
<select name="list" multiple="multiple" >
<option value="1.50">apple</option>
<option value="1.75">banana</option>
<option value="0.25">cranberry</option>
</select>
<br />
<button type="submit">submit</button><button type="reset">reset</button>
</form>
</body>
</html>

olivetomato
09-05-2003, 10:52 AM
yes!!! That is what I mean......thank you so much for helping out Fang. This is much appreciated