How to create a dynamic label?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jjluna13
    New Member
    • Sep 2006
    • 1

    How to create a dynamic label?

    Hello,

    I have two textboxes and one label in a form. I am looking to display the sum of both textboxes in the label on "real time", in fact to execute the sum when I lost the focus of one of the textboxes.

    For example at the beginning everything is in ceros. if I type "5" in the textbox a and press [TAB] (or click outside the textbox a) the label should be "5" and if I type "2" in the textbox b and press [TAB] (or click outside the textbox b) the label should be "7".

    I am new in java and web development and I really do not have idea of how two do it. I will appreciate any idea, tip or example.

    Thank you in advance.

    JJ
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You need to trigger the function onchange.

    Use the parseInt function to parse the string into an integer. If it's empty or not a number, change to zero by using the isNaN function.

    To change the label, access it by its id using document.getEle mentById() and use its innerHTML property or the DOM methods.

    Comment

    Working...