Jump to content

My Own Working Coding for Get Sum Total in Javascript


djbuddhi

Recommended Posts

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">

  function sumAll_1() {

      var reslultEID = document.getElementById("reslult");

      reslultEID.value = parseFloat(document.getElementById("t1").value);

  }

 

  function sumAll_2() {

      var reslultEID = document.getElementById("reslult");

      reslultEID.value = parseFloat(document.getElementById("t1").value) + parseFloat(document.getElementById("t2").value);

  }

</script>

</head>

 

<body >

<form name="form1" method="post" action="">

  <p> </p>

  <p> </p>

  <p> </p>

  <p> </p>

  <p> </p>

  <table width="316" border="1" align="center">

    <tr>

      <td width="140">Num1</td>

      <td width="160"><input type="text" name="t1" id="t1" onKeyUp="sumAll_1();" onChange="sumAll_2();" ></td>

    </tr>

    <tr>

      <td>Num2</td>

      <td><input type="text" name="t2" id="t2" onKeyUp="sumAll_2();" ></td>

    </tr>

    <tr>

      <td>Result</td>

      <td><input type="text" name="reslult" id="reslult"></td>

    </tr>

  </table>

  <p> </p>

</form>

</body>

</html>

 

Did you have a question? If you are posting your code as an example of how that should be done, then I would sieriously disagree with that methodology. There's no validation and the results are improperly displayed in some instances.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.