Solved

Using HTML form to calculte two follow

Posted on 2009-05-03
5
177 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
Comment Utility
0
 

Author Comment

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

thx
0
 

Author Comment

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

thx
0
 
LVL 2

Expert Comment

by:Manoj_a
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

772 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