User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,431 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,644 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Simple Math + Javascript

Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Simple Math + Javascript

  #2  
Jun 23rd, 2006
here's something to get you started.
<html>
<head>
<title>Our Products</title>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<style type="text/css"> 
	.submenu { padding-left:15px;}
		</style>
<script type="text/javascript">
<!--



function addItem(cb){

if(document.getElementById){
var elAmt = document.getElementById('Amt');
var elExtra = document.getElementById('extraAmt');
var elSub = document.getElementById('subAmt');
var elTax = document.getElementById('taxAmt');
var elTotal = document.getElementById('totAmt');
		var amount = parseFloat(elAmt.innerHTML);
		if(cb.checked){
		elExtra.innerHTML = "4.99";
		elSub.innerHTML = amount + 4.99;
		elTax.innerHTML = (amount + 4.99) * .06;
		elTotal.innerHTML = ((amount + 4.99) * 1.06);
		}
		else{
		elExtra.innerHTML = "0.00"
		elSub.innerHTML = "10.00"
		elTax.innerHTML = "0.60"
		elTotal.innerHTML = "10.60";
		}
	}
}


-->
</script>
</head>
<body>
<p><b>ProductList</b></p>

<br>
<br>
Product Information:

<table>
<tr><td>Item Description</td><td id='Amt'>10.00</td></tr>
<tr><td><input type=checkbox name=mType onclick="addItem(this)" value="prod3">Add extra product for 4.99</td><td id='extraAmt'>0.00</td></tr>
<tr><td>subtotal</td><td id='subAmt'>10.00</td></tr>
<tr><td>sales tax</td><td id='taxAmt'>0.60</td></tr>
<tr><td>grand total</td><td id='totAmt'>10.60</td></tr>
</table></form>
</body></html>
Reply With Quote  
All times are GMT -4. The time now is 5:28 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC