Javascript help!

admin

Administrator
Staff member
I really need your help! Im stuck on a javascript
question.

Create a web page which shows deatils of 3 products
like price etc.. Associated with each product should
be listbox which allows user to choose how many of
each(up to 5 of each).

3 checkboxes should be provided with 3 products
allowing user to opt for product insurance. This adds
20% to total cost of product.

finally values should be saved in cookie

here is my code so far...

cut + paste code to see web page.
thank you
steve


<html>
<head>

<title>E-commerce Site</title>
<SCRIPT LANGUAGE = JAVASCRIPT>
var total = document.myform.subtotal.value;

function calculate(){

if(document.myform.item1.checked == true){
total += (total * 0.20);
}


document.formName.subtotal1.value = total;



</script>

</head>


<body bgcolor="#00CCFF">


<h2 align="center"><u><font size="4"><b>Welcome to E-Commerce Website!</b></font></u></h2>
<p>&nbsp;</p>
<a href =http://www.webdeveloper.com/forum/archive/index.php/"products.htm"><font size="1">Home</font></a>
<br><br><br><br>
<p><font face="Arial Narrow">Below are the prices of our products we currently
have in stock.</font></p>
<br><br><br>


<!--"Start of Table" -->
<table width="893" border="1" BORDERCOLOR="#999999" cellspacing="0" cellpadding="2">
<tr>
<td bgcolor="#999999" height="25" align="center" width="173"><font color="#FFFFFF">Product</font></td>
<td bgcolor="#999999" align="center" width="50"><font color="#FFFFFF">Image</font></td>
<td bgcolor="#999999" align="center" width="86"><font color="#FFFFFF">Price</font></td>
<td bgcolor="#999999" align="center" width="197"><font color="#FFFFFF">Qty&nbsp;</font></td>
<td bgcolor="#999999" align="center" width="122"><font color="#FFFFFF">Insurance</font></td>
<td bgcolor="#999999" align="center" width="227"><font color="#FFFFFF">SubTotal</font></td>
</tr>

<tr>

<td align = "center" width="173" bgcolor="#eeeeee"><font face="MS Sans Serif">Sony Camcorder</font></td> <!--"shows name of product" -->
<td align = "center" width="50"><img border="0" src="cam.jpg" width="50" height="50"></td><!--"Shows picture of product" -->
<td align = "center" width="86" bgcolor="#eeeeee"><font face="MS Sans Serif">?094</font></td><!--"shows price of product" -->


<td align = "center" width="197" bgcolor="#eeeeee">
<p><font face="MS Sans Serif">Select quantity</font><!--"Displays listbox" -->
<select name = "pick1">
<option>1
<option>2
<option>3
<option>4
<option>5
</select></p>
</td>

<form method="post" name="myform">
<td align = "center" width="122" bgcolor="#eeeeee"><font face="MS Sans Serif">Insurance?</font><input name = "item1" type = "checkbox" onClick = "calculate()"></td><!--"Displays checkbox" -->

<td align = "center" width="227" bgcolor="#eeeeee">?lt;input type = "text" name = "subtotal1"></td><!--"Displays totalcost" -->
</form>
</tr>

<tr>

<td align = "center" width="173" bgcolor="#eeeeee"><font face="MS Sans Serif">Sony HiFi</font></td>
<td align = "center" width="50"><img border="0" src="HiFi.jpg" width="50" height="50"></td>
<td align = "center" width="86" bgcolor="#eeeeee"><font face="MS Sans Serif">?69</font></td>

<td align = "center" width="197" bgcolor="#eeeeee">
<p><font face="MS Sans Serif">Select quantity </font>
<select name = "pick2">
<option>1
<option>2
<option>3
<option>4
<option>5
</select></p>
</td>

<td align = "center" width="122" bgcolor="#eeeeee"><font face="MS Sans Serif">Insurance?</font><input name = "item2" type = "checkbox"></td>
<td align = "center" width="227" bgcolor="#eeeeee">?lt;input type = "text" name = "subtotal2"></td>
</tr>

<tr>

<td align = "center" width="173" bgcolor="#eeeeee"><font face="MS Sans Serif">MP3 Player</font></td>
<td align = "center" width="50"><img border="0" src="MP3.jpg" width="50" height="50"></td>
<td align = "center" width="86" bgcolor="#eeeeee"><font face="MS Sans Serif">?60</font></td>

<td align = "center" width="197" bgcolor="#eeeeee">
<p><font face="MS Sans Serif">Select quantity</font>
<select name = "pick3">
<option>1
<option>2
<option>3
<option>4
<option>5
</select></p>
</td>

<td align = "center" width="122" bgcolor="#eeeeee"><font face="MS Sans Serif">Insurance?</font><input name = "item3" type = "checkbox"></td>
<td align = "center" width="227" bgcolor="#eeeeee">?lt;input type = "text" name "subtotal3"</td>
</tr>

<tr>
<td colspan ="5" bgcolor = "999999">
<td bgcolor="#999999" align="center"><input type="button" value="Calculate" style="background-color:#ffffff; color:#000000; border:1px solid #000000; font-family:tahoma; font-size:8pt; letter-spacing=1px">
<input type="reset" value="Reset" style="background-color:#ffffff; color:#000000; border:1px solid #000000; font-family:tahoma; font-size:8pt; letter-spacing=1px"></td>
</tr>





</table>
</body>
 
Back
Top