Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Raghunathan
07/06/12 18:48
Read: 456 times
Chennai
India


 
#187875 - MyFirstJavascript calculator!!
Responding to: Per Westermark's previous message
Hi Per,
So have been spending some time on the net trying to learn how to say "HelloWorld" in JS. Looks not very difficult as I could write the code below rather fast ( OK adapted it from an example - ). I now want to bring in a Option button for English / Metric units and based on the selection do the relevant calculation. I am sure thats going to be possible too ??


<html>   
<head>    
<title> Fluid Power Calculator </title>  
    
  
<script language="javascript" type="text/javascript">  
function findvelocity(){  
a=Number(document.calculator.number1.value);  
b=Number(document.calculator.number2.value);  
c=((a*1000/60)/ ((b/10)^2 *0.785))*10;  
document.calculator.total.value=c;  
}  
</script>  
  

</head>  
  
<body>   
<!-- Opening a HTML Form. -->   
<form name="calculator">  

<p> 
<!-- Here user will enter 1st number. -->   
Flow (lpm) : <input type="text" name="number1"> 
</p>  
   
<p> 
<!-- Here user will enter 2nd number. -->   
Pipe ID (mm): <input type="text" name="number2">   
</p>
  
<p>  
<!-- Here result will be displayed. -->   
Velocity ( mm/sec): <input type="text" name="total">   
</p>  
  
<!-- Here respective button when clicked, calls only respective artimetic function. -->   
<input type="button" value="CALCULATE" onclick="javascript:findvelocity();">  

  
</form>  
</body>  
</html>  
 

For those not very familiar with HTML : To try the code, just copy paste the code into notepad and save it as a html file. Double click and it opens in a IE9 browser ( or any browser ?)and even calculates !!

Raghu

List of 18 messages in thread
TopicAuthorDate
Publishing a Excel file on website      Raghunathan      07/03/12 04:02      
   Excel is not a web standard!      Oliver Sedlacek      07/03/12 22:58      
      Javascript      Per Westermark      07/03/12 23:27      
         The WikiLink      Raghunathan      07/05/12 14:44      
            Extra ")"      Per Westermark      07/05/12 19:58      
               MyFirstJavascript calculator!!      Raghunathan      07/06/12 18:48      
                  Always break problem into smaller pieces      Per Westermark      07/06/12 22:25      
   Just let them download it      Andy Neil      07/04/12 06:28      
      Download or run on site?      Joseph Hebert      07/04/12 07:46      
         Applet?      Per Westermark      07/04/12 12:42      
            Applet      Joseph Hebert      07/06/12 08:39      
               So - you don't care about electronic terms either?      Per Westermark      07/06/12 09:51      
                  That's the orangest bushel of apples I've ever seen.      Joseph Hebert      07/06/12 11:19      
   Try the Google Approach      Michael Karas      07/04/12 12:57      
      Making my requirememt more clear...      Raghunathan      07/05/12 03:49      
         That's a different problem - not a clarification!      Andy Neil      07/05/12 05:14      
         Excel dead end?      Oliver Sedlacek      07/06/12 02:25      
         People can, if they need, use OpenOffice ... right?      Richard Erlacher      07/07/12 03:09      

Back to Subject List