You are here: HomeForums » Javascript » Simple Javascript function to add textbox on the onclick event

Simple Javascript function to add textbox on the onclick event (1 post)

in Forums » Javascript
  • Started 1 month ago by thdadmin

thdadmin (administrator)

This function is very simple and might help you while creating an admin panel for example if you want to add multiple entries in a database.

function addTextbox() {
var my_div = document.getElementById("tb");
var tbs = 'a';
tbs += my_div.parentNode.getElementsByTagName('input').length;
var element=null;
try {
    element = document.createElement("<input name='"+tb+"' type='text' />");
    }
catch (e) {
    element = document.createElement("input");
    element.setAttribute("name", tbs);
    element.setAttribute("type", "text");
    }
my_div.parentNode.appendChild(element);
}

If you have other functions that do the same thing let me know!

Posted 1 month ago #

Reply

You must log in to post.