add dynamic textbox
Moderator: General Moderators
-
Sandip Ranipa
- Forum Newbie
- Posts: 1
- Joined: Tue Aug 16, 2011 8:57 am
add dynamic textbox
I am new to php and i want to know to how can i add new textbox to my web page when i press tab key from keyboard the new textbox should be created and this process should go on.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: add dynamic textbox
The easiest way to do that is to attach a keypress event. If it detects that a tab was clicked, it creates a clone of the textbox. This can be done pretty easily with Mootools. To listen for a tab, attach an event to it with addEvent.
Not sure if that actually works, haven't tested it. Replace 'elementId' with whatever the ID attribute of the first text box is set to. And put '[]' at the end of the name attribute.
Code: Select all
$('elementId').addEvent('keydown', function(event){
if (event.key == 'tab' && !event.shift) {
event.target.clone().inject(event.target, 'after');
return false;
}
});