?
Solved

Using HTML form to calculte two follow

Posted on 2009-05-03
5
Medium Priority
?
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

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 200 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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.
Suggested Courses

770 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