add dynamic textbox

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Sandip Ranipa
Forum Newbie
Posts: 1
Joined: Tue Aug 16, 2011 8:57 am

add dynamic textbox

Post by Sandip Ranipa »

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.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: add dynamic textbox

Post by Jonah Bron »

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.

Code: Select all

$('elementId').addEvent('keydown', function(event){
    if (event.key == 'tab' && !event.shift) {
        event.target.clone().inject(event.target, 'after');
        return false;
    }
});
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.
Post Reply