Simple Web jsp question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sl1ver
    New Member
    • Mar 2009
    • 196

    Simple Web jsp question

    say i add a textbox in html and a button, how do i assign functions to it

    e.g. how will i write a piece of code that will know when the button has been pressed and will set a label to what was typed in the textbox?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    standard way:

    Code:
    // say, the textbox has an id of "tb1"
    var tb = document.getElementById("tb1");
    
    // type is e.g. "click", "change", …
    // your_function is the name of the function to be executed 
    //   without brackets or quotation marks
    tb.addEventListener(type, your_function, false);
    the function your_function can now do anything necessary to set the label (or whatever). you may excessively use this.

    Comment

    Working...