Solved

Using HTML form to calculte two follow

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
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…
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…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

777 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