Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old January 29th, 2006, 02:04 AM
sessionmedia sessionmedia is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NY, USA
Posts: 19 sessionmedia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to sessionmedia
javascript math function

Can anyone help me modify the code seen here
http://javascript.internet.com/forms/auto-sum-form-boxes.html

what I want to do is have a drop down box and three other fields called quantity price total

in the drop down the selections would be per/m and ea

if per/m is selected then I need to do this math function:
quantity x's price devided by 1000 = total

if ea is selected then
quantity x's price = total

can anyone tell me how to modify the code from the javasite to do this I know I need a switch statment

thanks


Reply With Quote
  #2  
Old January 29th, 2006, 10:48 PM
brut brut is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 367 brut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 30 sec
Reputation Power: 2
RE: javascript math function

This?
Code:
<html>
<head>
 <script language="javascript">

	function startCalc(){
  		interval = setInterval("calc()",1);
	}

	function calc(){
	  one = document.autoSumForm.firstBox.value;
	  two = document.autoSumForm.secondBox.value;
     per = document.autoSumForm.per.options[document.autoSumForm.per.selectedIndex].value;
	  if(per=="gr"){
		  one=one/1000;
	  }
	  document.autoSumForm.thirdBox.value = one * two;
	}

	function stopCalc(){
	  clearInterval(interval);
	}

 </script>
</head>
<body>

<form name="autoSumForm">
Qty.<input type=text name="firstBox" size="5" value="" onFocus="startCalc();" onBlur="stopCalc();">
 @ $<input type=text name="secondBox" size="5" value="" onFocus="startCalc();" onBlur="stopCalc();">
<select name="per" id="per" onFocus="startCalc();" onBlur="stopCalc();">
 <option value="ea">Each</option>
 <option value="gr">Per/M</option>
</select>
 = 
$<input type=text size="5" name="thirdBox">
</form>

</body>
</head>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > javascript math function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT