What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » using js to add a form input, but retaining typed info?

using js to add a form input, but retaining typed info?
Author: Message:
felipEx
Scripting Contest Winner
***


Posts: 378
Reputation: 24
35 / Male / Flag
Joined: Jun 2006
RE: using js to add a form input, but retaining typed info?
Use createElement and appendChild

Javascript code:
function extend(m, e){
    var e = e || this;
    for (var x in m) e[x] = m[x];
    return e;
};
 
function create(type, opt, parent){
    var el = document.createElement(type);
 
    if (opt.style){
        extend(opt.style,el.style);
    }
 
    delete opt.style;
 
    extend(opt,el);
 
    if (parent){
        parent.appendChild(el);
    }
 
    return el;
}
 
 
function add_input(){
create("input", {type: "text"}, document.getElementById('input_container'));
create("br", {},  document.getElementById('input_container'));
//document.getElementById('input_container').innerHTML += '<input type="text"><br />';
}


this should do the trick :)

This post was edited on 07-20-2009 at 02:30 PM by felipEx.
07-19-2009 11:14 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
using js to add a form input, but retaining typed info? - by stoshrocket on 07-19-2009 at 10:27 PM
RE: using js to add a form input, but retaining typed info? - by felipEx on 07-19-2009 at 11:14 PM
RE: using js to add a form input, but retaining typed info? - by stoshrocket on 07-20-2009 at 03:13 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On