Add More Text Box

In the Add More Text Box script is use to create one or more a text box dynamically through DOM.

Demo :



Text Box :

Example :

You click a add more button and see more text box at broswer.

Code :

Following code is Add More Text Box script code if you need to copy and use to your web site.


<script>
function add_more_text_box(parent_id, child_name, child_id)
{
  var myTable=document.getElementById(parent_id);
  var oDiv, oInput;
  oDiv = document.createElement('div');
  oDiv.setAttribute('id', 'Name');
  myTable.appendChild(oDiv);

  oInput = document.createElement('input');
  oInput.setAttribute('type', 'text');
  oInput.setAttribute('name', child_name);
  oInput.setAttribute('id', child_id);
  oDiv.appendChild(oInput);
}
var child_id = 1;
function child()
{
  return child_id++;
}
</script>

<form id="add_more" name="add_more" method="post" action="">
<div id="add_more_div">
  <div><input type="text" id="add_more" name="add_more[]" ></div>
</div>
<a href="javascript:;" onclick="return add_more_text_box('add_more_div','add_more[]',child());">add more</a>
</form>

In the above add_more_text_box() is use to create more a text box.That functions have three arguments that is parent_id, child_name and child_id.In the parent_id is replace div id and add_more is parent text box name and child_id is to would replace to child text box.

Free Download Script:

If you need to Add More Text Box Script click and download from following zip file.

Download




Content