Solved

Using HTML form to calculte two follow

Posted on 2009-05-03
5
178 Views
Last Modified: 2013-11-19
Hi,
I have two value lest say
x=4
y=6
I want to enter both in FORM in HTML and result appear Z as sum
0
Comment
Question by:miziri
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Manoj_a
ID: 24289358
0
 

Author Comment

by:miziri
ID: 24289371
Hi,
friend I have look that cis that two complex is the more easy way

thx
0
 

Author Comment

by:miziri
ID: 24289423
Hi,
Can please me simple of add to number ,this very complex and long

thx
0
 
LVL 2

Expert Comment

by:Manoj_a
ID: 24289618
Have just taken out the unnecessary stuff to make it easier for u..

<html>
<head>
<script language="javascript">
function calculateNumbers()
{
FirstNumber = document.frmCalculate.txtFirst.value
FirstNumber = Number(FirstNumber)
SecondNumber = document.frmCalculate.txtSecond.value;
SecondNumber = Number(SecondNumber)
Total = (FirstNumber+SecondNumber)
document.frmCalculate.txtTotal.value = Total
}
</script>
</head>
<form name="frmCalculate">
<input type="text" size="2" name="txtFirst" maxlength="2" class="textField" onMouseOver="this.className = 'textFieldHover'" OnMouseOut="this.className = 'textField'">+</input>
<input type="text" size="2" name="txtSecond" maxlength="2" class="textField" onMouseOver="this.className = 'textFieldHover'" OnMouseOut="this.className = 'textField'">=</input>
<input type="text" size="2" name="txtTotal" maxlength="0" class="textField" onMouseOut="this.className = 'textField'" value="0"></input><br>
<input type="button" value="Add" name="buttonCalculate" onMouseOver="this.className = 'formButtonStateHover'" onMouseOut="this.className = 'formButtonStateNormal'" onFocus="if(this.blur)this.blur()" class="formButtonStateNormal" onClick="calculateNumbers()"></input>
<input type="reset" value="Reset" name="buttonReset" onMouseOver="this.className = 'formButtonStateHover'" onMouseOut="this.className = 'formButtonStateNormal'" onFocus="if(this.blur)this.blur()" class="formButtonStateNormal"></input>
</form>
</body>
</html>
0
 
LVL 2

Accepted Solution

by:
Manoj_a earned 50 total points
ID: 24289644
Further simplified :
 
<html>
<head>
<script language="javascript">
function calculateNumbers()
{
FirstNumber = document.frmCalculate.txtFirst.value
FirstNumber = Number(FirstNumber)
SecondNumber = document.frmCalculate.txtSecond.value;
SecondNumber = Number(SecondNumber)
Total = (FirstNumber+SecondNumber)
document.frmCalculate.txtTotal.value = Total
}
</script>
</head>
<form name="frmCalculate">
<input type="text" size="2" name="txtFirst" maxlength="2" >+</input>
<input type="text" size="2" name="txtSecond" maxlength="2">=</input>
<input type="text" size="2" name="txtTotal" maxlength="0" value="0"></input><br>
<input type="button" value="Add" name="buttonCalculate" onClick="calculateNumbers()"></input>
<input type="reset" value="Reset" name="buttonReset"></input>
</form>
</body>
</html>  
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now