Skip to content
Advertisement

Dynamically creating a textbox with a Javascript onkeyup event that takes parameters

What I have is a single textbox. If the user hits the maxlength of it, I want to create a new textbox and then change focus to it so they can continue typing.

To accomplish this, I am trying to dynamically create textboxes that have an onkeyup event tied to them. To do this I am using document.createElement and the creation of the element works. The problem is that I can’t get the parameters (the id of the current textbox and the id of the one to be created) to pass correctly and they are simply variables. Before I pass them I can test them and they are fine, but in the method they are null.

Here is my code:

JavaScript


I am pretty new to Javascript, so if this is completely fubar’d, I apologize.
Any help is appreciated.

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement