Ciao a tutti, ho trovato su internet questo script che permette di aggiungere o rimuovere i campi in un determinato div.
codice:
var arrInput = new Array(0);
var arrInputValue = new Array(0);
var parah;

function addInput(type)
 {
  arrInput.push(arrInput.length);

  arrInputValue.push("");
  display(type);
 }

function display(type)
 {
  if(type == 'school')
   {parah = 'parah_school'}
  else if(type == 'work')
   {parah = 'parah_work'}
  else
   {parah = 'parah'}

  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='s"+id+"' name='s"+id+"' size='30' style='margin-bottom:10px' onChange='javascript:saveValue("+id+", this.value)' value='"+value+"'>
";
 }

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

  display(type); 
 }
Ho provato a modificare lo script perché dovrei inserirlo più di una volta nella stessa pagina:
codice:
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='s"+id+"' name='s"+id+"' size='30' style='margin-bottom:10px' onChange='javascript:saveValue("+id+", this.value)' value='"+value+"'>
";
 }

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

  display(); 
 }
Ma cmq quando richiamo la funzione aggiungi input nel div 1 questa inserirà un numero di input pari alla somma dei div inserito fino ad adesso +1.

Sapete aiutarmi a risolvere?