Solved

Using HTML form to calculte two follow

Posted on 2009-05-03
5
182 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

688 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