<!doctype html>
<meta charset= "UTF-8" >
<title> Shopping Cart Automatic pricing </title>
<script type= "Text/javascript" src= "Jquery-min.js" ></script>
<script type= "Text/javascript" >
$ (function () {
$ (". SE"). Change (function (Oeven) {
var num = $ (this). Find ("option:selected"). Text ();
var Price = $ (This). Parent (). Next (). text ();
$ (this). Parent (). Next (). Next (). text (Num*price);
Getinall ();//Calculate the price of all items
});
})
function Getinall ()
{
var len = $ ("#PriceTable tbody"). Children ("tr"). Length;
var pricecount=0;
for (Var i=0;i<len;i++)
{
var tempdata=rows[i];
var Price1 = $ ("#PriceTable tbody tr:eq (" +i+ ") Td:eq (4)"). text ();
Pricecount=parsefloat (Pricecount) +parsefloat (Price1);
}
$ ("#PriceTable tfoot tr td:eq (1)"). Text (Pricecount);
}
</script>
<style type= "Text/css" >
Table input[type=text]{width:32px;}
</style>
<body>
<div>
<table id= "Pricetable" >
<thead><tr><td> Item number </td><td> item name </TD><TD > Quantity </td><td> Price </td><td> Subtotal </td></tr></thead>
<tbody>
<tr>
<TD >jsp_123</td>
<TD > Computers </td>
<td>
<select name= "se" class= "se" >
<option value= "1" >1</option>
<option value= "1" >2</option>
<option value= "1" >3</option>
<option value= "1" >4</option>
<option value= "1" >5</option>
</select>
</td>
<TD >1950</td>
<TD >1950</td>
</tr>
<tr>
<TD >jsp_123</td>
<TD > Computers </td>
<td>
<select name= "se" class= "se" >
<option value= "1" >1</option>
<option value= "1" >2</option>
<option value= "1" >3</option>
<option value= "1" >4</option>
<option value= "1" >5</option>
</select>
</td>
<TD >1950</td>
<TD >1950</td>
</tr>
<tr>
<TD >jsp_123</td>
<TD > Computers </td>
<td>
<select name= "se" class= "se" >
<option value= "1" >1</option>
<option value= "1" >2</option>
<option value= "1" >3</option>
<option value= "1" >4</option>
<option value= "1" >5</option>
</select>
</td>
<TD >1950</td>
<TD >1950</td>
</tr>
</tbody>
<tfoot>
<tr><td> Total: </td><td colspan= "4" >5850</td></tr>
</tfoot>
</table>
</div>
<input type= "button" onclick= "Getinall ()" Value= calculation "/>
</body>
Shopping Cart front page code