grazie per la tua risposta ma al click sarebbe meglio utilizzare onchange forse...
Comunque ho trovato questo script che potrebbe fare al caso mio ugualmente, anche se non è proprio quello che cercavo.
Ma a questo script c'è un problema, inserisce campi file infiniti, come posso limitare che si aggiungano max solo 10 campi file?
Grazie
G.
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript">
<!--
var files = 1;
function add() {
if (document.createElement && document.getElementById && document.getElementsByTagName) {
// crea elementi
var inputField = document.createElement("input");
var brField = document.createElement("br");
// setta attributi
inputField.setAttribute("type","file");
inputField.setAttribute("name","file" + files);
// appendi al relativo padre
document.getElementById('files').appendChild(brField);
document.getElementById('files').appendChild(inputField);
// incrementa variabile globale
files++;
}
}
function del() {
if (document.removeChild && document.getElementById && document.getElementsByTagName) {
// se non e' la prima riga
if (files > 1) {
// decrementa variabile globale
files--;
// rimuovi
var inputField = document.getElementById('files').getElementsByTagName('input')[files];
var brField = document.getElementById('files').getElementsByTagName('br')[files-1];
document.getElementById('files').removeChild(inputField);
document.getElementById('files').removeChild(brField);
}
}
}
//-->
</script>
</head>
<body>
<form name="modulo" action="caricaimmagine.asp" method="post" enctype="multipart/form-data">
<p id="files">
<input type="file" name="file1" />
</p>
Aggiungi foto <a href="javascript:del()">
Rimuovi foto</a></p>
<input name="invio" type="submit" id="invio" value="Upload files">
<input type="reset" name="Submit2" value="Reimposta">
</form>
</body>
</html>