Prova questo.
2 cose :
- in un form bisogna usare name per poter mandare i dati tramite POST. Ovviamente puoi usare id con il JS ma ricordati che per inviare i dati html ha bisogno solo del name.
- Per mandare i dati bisogna usare un input di tipo submit.
codice HTML:
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<script>
var indice = 0;
function inserisci() {
indice++;
var html = "";
html = '<br/><div id="subDiv'+indice+'">Modulo:'+indice+'<br/>';
html = html + 'Nome :<input type="text" name="nome'+indice+'" /><br/>';
html = html + 'Cognome :<input type="text" name="cognome'+indice+'" /><br/>';
html = html + 'Indirizzo :<input type="text" name="indirizzo'+indice+'" /><br/>';
html = html + 'Città :<input type="text" name="citta'+indice+'" /><br/>';
html = html + 'CAP :<input type="text" name="cap'+indice+'" /><br/>';
html = html + 'Provincia :<input type="text" name="provincia'+indice+'" /></div>';
document.getElementById('mydiv').innerHTML = document.getElementById('mydiv').innerHTML + html;
}
</script>
</head>
<body>
<input type="button" id="inserisci" value="inserisci" onclick="inserisci() " >
<hr/>
<form name="modulo" action="link.php" method="post">
<div id="mydiv">
</div>
<input type="submit" name="invia" value="Invia">
</form>
<hr/>
</body>
</html>