Friday 10, February 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    Forum    |    About Us    |    Contact Us

  Dynamically Add and Remove HTML Controlls using JavaScript

this script can be used to add HTML controls to your forms dynamically.
Cut & Paste Script

<html>
<head>
<title>Add Remove HTML Controls</title>
<script>
var arrInput = new Array(0);
  var arrInputValue = new Array(0);

function addInput() {
  arrInput.push(arrInput.length);
  arrInputValue.push("");
  display();
}

function display() {
  document.getElementById('parah').innerHTML="";
  for (intI=0;intI<arrInput.length;intI++) {
    document.getElementById('parah').innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
  }
}

function saveValue(intId,strValue) {
  arrInputValue[intId]=strValue;


function createInput(id,value) {
  return "<input type='text' id='test "+ id +"' onChange='javascript:saveValue("+ id +",this.value)' value='"+ value +"'><br>";
}

function deleteInput() {
  if (arrInput.length > 0) {
     arrInput.pop();
     arrInputValue.pop();
  }
  display();
}

</script>
</head>
<body>
<p id="parah">Click below to dynamically add and remove input boxes</p>

<a href="javascript:addInput()">Add more input field(s)</a><br>
<a href="javascript:deleteInput()">Remove field(s)</a>
</body>
</html>

 

 
   
     RELATED SCRIPTS
 
Accept Disclaimer Radio Button Example JavaScript
Confirm your visitor's approval by requiring their name before continuing on. Useful if you require your visitors to accept a disclaimer before downloading software or visiting a section of your members-only site. Could be used with a cookie....more »
Category : JavaScript Examples Hits : 925
   
Drop Down World Clock Using JavaScript
Look up the time of various cities around the world easily with this useful script! Configurable to use cities of your choice....more »
Category : JavaScript Examples Hits : 455
   
Add Input Fields Dynamically using JavaScript
Use this script to upload files. As a file is selected, another input field is automatically added....more »
Category : JavaScript Examples Hits : 415
   
javascript collapsible menu script
Here is a javascript collapsible menu that turn into submenus. Useful for things like categorizing subjects and a table of contents....more »
Category : JavaScript Examples Hits : 408
   
Creating a Popup Once Window using JavaScript
Popup windows are everywhere on the web. Use this script to add one to your site that is NOT annoying, since it only pops up once. Try leaving then coming back to this page- no more popup. ...more »
Category : JavaScript Examples Hits : 323
   
   
SCRIPT CATEGORIES
 
  C Programs
C Programs scripts
  C++ Programs
C++ Programs scripts
  Java Programs
Java Programs scripts
  JavaScript Examples
JavaScript Examples scripts
  PHP Examples
PHP Examples scripts
  VBScript Examples
VBScript Examples scripts
 
 
 
POPULAR E-BOOKS
 
Download From Ebay Zero to Hero  Ebook From Ebay Zero to Hero
   
Download Generate a Passive Income  Ebook Generate a Passive Income
   
Download Project Oberon - The Design of an Operating System and Compiler  Ebook Project Oberon - The Design of an Operating System and Compiler
   
Download Special Report  Ebook Special Report
   
Download How To Get Rich From Any MLM Program Ebook How To Get Rich From Any MLM Program
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz