0

I have 2 text boxes A and B I want the answer A-B displayed on A Text box 'onchange' event of B
Please help me
Thanks
God Bless

Eranga

6
Contributors
7
Replies
9
Views
6 Years
Discussion Span
Last Post by ErangaD
0

hi,
first, please try with some code then post your code here for help.
Anyway try with example script:

function test()
{
var x=document.getElementById("A");
document.getElementById("A")=x-document.getElementById("B");
}

Use this test() on'onchange' for A text box.

Please post your required peice of code..
All the best.

0

I think this code will help you .:-)

<HTML>
  <HEAD>
  <TITLE>Test Input</TITLE>
  <SCRIPT LANGUAGE="JavaScript">
  
  function validate (form) {
   var First = form.inputbox.value;
   var Sec = form.inputbox2.value;
   alert( " Result = " +First+ "-" +Sec);
   document.getElementById("nm").value=First+ "-" +Sec;
  }
  </SCRIPT>
  </HEAD>
  <BODY>
  <FORM NAME="myform" ACTION="" METHOD="GET">Enter something in the box: <BR>
 First Name <INPUT id ="nm" TYPE="text" NAME="inputbox" VALUE="" ><P>
 Second Name  <INPUT TYPE="text" NAME="inputbox2" VALUE="" OnChange="validate(this.form)" ><P>
  
  </FORM>
  </BODY>
  </HTML>
0

document.getElementById("nm").value=First+ "-" +Sec line do no give the answer
it just shows the equation
ex: 500-400 answer should be 100 but it show as 500-400

Please help
thanks
God Bless

Eranga

0

How do a equation on a formatted text box
EX: TextBox A = formatted(14,500.00) Text box B - formatted(1,1200.00)
TextBox A = 14,500.00 - 1,1200.00 answer comes as 'Nan'

Please help
Thanks
God Bless

Eranga

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.