DragonTooth™
(Requested) Calculator Code - HTML & JavaScript DragonToothBanner-4
DragonTooth™
(Requested) Calculator Code - HTML & JavaScript DragonToothBanner-4
DragonTooth™
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Welcome To DragonTooth (GameDEV). Our Administrators: Emptrix, Amethyst, Shizuko~Conan, Yamino. To Contact Us, e-mail: Dragon_Tooth@live.com.
 
HomeLatest imagesSearchRegisterLog in
Welcome to DragonToothDEV Forum. We are currently not taking anymore new users, however we will accept users that has Friend's Recommendation. Members who's friends are joining please pm one of the Administrators the username of your friend's newly created account to get it activated.

 

 (Requested) Calculator Code - HTML & JavaScript

Go down 
AuthorMessage
Emptrix
Staff Administrator
Emptrix


Posts : 1218
Points : 1916
Reputation : 13
Join date : 2009-05-09
Age : 33
Location : The World That Never Was

(Requested) Calculator Code - HTML & JavaScript Empty
PostSubject: (Requested) Calculator Code - HTML & JavaScript   (Requested) Calculator Code - HTML & JavaScript EmptyMon Nov 15, 2010 11:57 am

As requested by burma, here: Very Happy

Code:

<!Author: Emptrix>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">
    <title>Welcome</title>
    <script type="text/javascript">
      function calculate() {
         var n1 = document.form1.num1_txt.value;
         var n2 = document.form1.num2_txt.value;
         
         if (isNaN(n1)) {
         alert("Number 1 must be a number.");
         document.form1.num1_txt.focus();
         document.form1.num1_txt.value = "";
         } else if (isNaN(n2)) {
         alert("Number 2 must be a number.");
         document.form1.num2_txt.focus();
         document.form1.num2_txt.value = "";
         } else if (n2 == "") {
         alert("Number 2 is required.");
         document.form1.num2_txt.focus();
         document.form1.num2_txt.value = "";
         } else if (n1 == "") {
         alert("Number 1 is required.");
         document.form1.num1_txt.focus();
         document.form1.num1_txt.value = "";
         }
         
         var result = parseInt(n1) + parseInt(n2);

         document.form1.result_txt.value=result;
      }
    </script>
  </head>
  <body>
  <form name="form1" allow="" method="post">
   <table>
   <tr>
      <td>Enter Number 1:</td>
      <td><input type="text" name="num1_txt" value="" /></td>
   </tr>
   <tr>
      <td>Enter Number 2:</td>
      <td><input type="text" name="num2_txt" value="" /></td>
   </tr>
   <tr>
      <td>Result:</td>
      <td><input type="text" name="result_txt" value="" readonly="readonly" /></td>
   </tr>
   <tr>
      <td><input type="button" name="button" value="calculate" onClick="calculate()" /></td>
   </tr>   
   </table>
  </form>
 

  <textarea rows="20" cols="150">
    <script type="text/javascript">
      function calculate() {
         var n1 = document.form1.num1_txt.value;
         var n2 = document.form1.num2_txt.value;
         
         if (isNaN(n1)) {
         alert("Number 1 must be a number.");
         document.form1.num1_txt.focus();
         document.form1.num1_txt.value = "";
         } else if (isNaN(n2)) {
         alert("Number 2 must be a number.");
         document.form1.num2_txt.focus();
         document.form1.num2_txt.value = "";
         } else if (n2 == "") {
         alert("Number 2 is required.");
         document.form1.num2_txt.focus();
         document.form1.num2_txt.value = "";
         } else if (n1 == "") {
         alert("Number 1 is required.");
         document.form1.num1_txt.focus();
         document.form1.num1_txt.value = "";
         }
         
         var result = parseInt(n1) + parseInt(n2);

         document.form1.result_txt.value=result;
      }
    </script>
  </head>
  <body>
  <form name="form1" allow="" method="post">
   <table>
   <tr>
      <td>Enter Number 1:</td>
      <td><input type="text" name="num1_txt" value="" /></td>
   </tr>
   <tr>
      <td>Enter Number 2:</td>
      <td><input type="text" name="num2_txt" value="" /></td>
   </tr>
   <tr>
      <td>Result:</td>
      <td><input type="text" name="result_txt" value="" readonly="readonly" /></td>
   </tr>
   <tr>
      <td><input type="button" name="button" value="calculate" onClick="calculate()" /></td>
   </tr>   
   </table>
  </form>
 

   </textarea>
  </body>
</html>


Last edited by Emptrix on Tue Nov 16, 2010 12:17 pm; edited 1 time in total
Back to top Go down
http://emptrix.tk
 
(Requested) Calculator Code - HTML & JavaScript
Back to top 
Page 1 of 1
 Similar topics
-
» (Requested) Check for Items code - HTML & Javascript
» Salted hash code

Permissions in this forum:You cannot reply to topics in this forum
DragonTooth™ :: Help & Support :: Help & Requests-
Jump to: