javascript - Calculate values of textboxes automatically using jQuery -


I want to calculate the value of 1 2 text box without the command button. Example I have 3 text boxes.

The first 2, where the numbers will be input and the last 1 is the sum or the product and so on. Now I want to auto-compute it. For example I have inputed values ​​2 and 3 on the first 2 text boxes, then automatically the sum or product or whatever results will be displayed in the 3 text boxes. How am I doing this? Thanks

  & lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; ($ ('#texttwo' ()); Var result = texton + textover; $ ('# result'). Val (result.toFixed (2));}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Input type = "text" name = "value1" id = "textone" & gt; & Lt; Input type = "text" name = "value2" id = "texttwo" & gt; & Lt; Input type = "text" name = "results" id = "result" & gt; & Lt; / Body & gt; & Lt; / Head & gt;  

You can get it using jQuery. Find it in your & lt; Head & gt;

  & lt; Script jquery /1.11.1/jquery.min.js"></script> insert jQuery into your project by entering script src = "http://ajax.googleapis.com/ajax/libs  

Then, at the end of the file:

  & lt; Script & gt; ($ ('#texttwo' ()); Var result = texton + textover; $ ('# result'). Val (result.toFixed (2));}); & Lt; / Script & gt;  

This will give you results whenever you change the value of the second box.

You will also need to:

Change

  & lt; Input type = name of text = value1 & gt; & Lt; Input type = name of text = value2> & Lt; Input type = text name = result & gt;  

to:

  & lt; Input type = "text" name = "value1" id = "textone" & gt; & Lt; Input type = "text" name = "value2" id = "texttwo" & gt; & Lt; Input type = "text" name = "results" id = "result" & gt; This is my complete file:  
  and 



  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -