Find difference of values in two textboxes and display result in the third textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manishamca
    New Member
    • Mar 2008
    • 17

    Find difference of values in two textboxes and display result in the third textbox

    can anyone say me how to find the difference of values present in two textbox and display the result in the third textbox.

    for eg:
    <input type=text name=t1 value=123>
    <input type=text name=t2 value=20>
    <input type=text name=t3 value=103>
    in the t3 textbox the difference of tw otextbox shuld be displayed as soon as we focus in the third textbox.
    can anyone plz help me how to find difference of two textbox and make that difference value as the value of third textbox.

    Thanx in advance
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    Code:
    <script>
        var tCellValue = document.getElementById('t3').value;
        alert('  T3 value is '+tCellValue)
    </script>
    By the way your attributes should be surrounded by quotes.

    So this.

    Code:
           <input type=text name=t1 value=123>
           <input type=text name=t2 value=20>
          <input type=text name=t3 value=103>
    Should be

    Code:
           <input type="text" name="t1" value="123" >
           <input type="text" name="t2" value="20" >
          <input type="text" name="t3" value="103" >

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      manishamca, please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).

      This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

      MODERATOR

      Comment

      Working...