html - eventlistener fires when I add it in javascript -


What am I trying to do, when they are not necessary / necessary then add and remove text boxes from the table. The function is required to execute when a user types in a text box. The page loads with several text boxes, in which this function is in the form of a single listener. The code is bothering me, so I put a breakpoint (GC Developer Tool) at the beginning of the function and what is typed in a text box is on the line:

  Input AddEventListener ("keypress", update textbox (table name, input.id));   

Allows to launch the execution function! function updated textbox (table name, element) {var numcells = document.getElementById (table name). Rows.length - 1; Var lastTxt = document.getElementById (table name + numCells); Var curNum = element.id.replace (/ ^ \ D + / g, ''); If (curnum! = Numcells & amp; amp; element.text == "" & amp; amp; amp; amp; last.Txt.text == "") {document.getElementById (tablename) .deleteRow (numCells); } And if (element.text! = "" & Amp; amp;; & amp; Last Text. Text! = "") {Var input = document.createElement ("Input"); Input.type = "text"; NextNum = numCells + 2; Input.id = tagname + next number; Input.addEventListener ("keyboard", updated textbox (table name, input.ind)); NewRow = document.getElementById (tablename) .inertRow (); NewCell = newRow.insertCell (); NewCell.appendChild (input); }}

You are calling the function, so it is called instead Wrap it in an anonymous function.

  Input. AddEventListener ("keypress", function () {updateTextBox (table name, input.ed)); });    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -