ce l'ho fatta!
grazie per gli aiuti
[sto scherzando]
comunque, posto la soluzione che ho trovato casomai dovesse servire a qualcuno.
innanzitutto l'ho fatto con i checkbox, perché con i radio avevo problemi, avendo praticamente tutti gli stessi nomi, e non riuscivo ad ovviare.
Con i check funziona, solo che si possono selezionare più opzioni per immagine, ma spero che il cliente non sia così sciocco [
] da farlo
prima avevo dimenticato di mettere i radio [che ora sono checkbox] anche in corrispondeza del link Rimuovi, quindi all'interno del div nascosto.
ma bando alle ciance e veniamo al dunque; posto solo le modifiche in quanto il resto ce l'avete tutti
funzione mostraform() del file upload.class.php:
codice:
function mostraform(){
//FORM PER EFFETTUARE L'UPLOAD
echo "<html>
<head>
<script type=\"text/javascript\" src=\"esterno.js\"></script>
</head>
<body>
<form action=\"{$_SERVER['PHP_SELF']}\" method=\"POST\" name=\"modulo\" enctype=\"multipart/form-data\">
<div id=\"attachment\" style=\"display:none\" class=\"normale\">
<input id=\"file\" name=\"file\" type=\"file\" size=\"55\" />
<input name=\"fase\" type=\"checkbox\" value=\"1\" />1
<input name=\"fase\" type=\"checkbox\" value=\"2\" />2
<input name=\"fase\" type=\"checkbox\" value=\"3\" />3
<input name=\"fase\" type=\"checkbox\" value=\"4\" />4
<input name=\"fase\" type=\"checkbox\" value=\"5\" />5
<input name=\"fase\" type=\"checkbox\" value=\"6\" />6
<a href=\"#\" onclick=\"javascript:removeFile(this.parentNode.parentNode,this.parentNode);\"> Rimuovi</a>
</div>
<div id=\"attachments\">
<span class=\"normale\"><a id=\"addupload\" href=\"javascript:addUpload('file', 'fase'); \">Aggiungi file</a> [clicca sul link se vuoi abbinare più di un file per la stessa ricetta]
</span>
<input name=\"file[]\" type=\"file\" size=\"55\" />
<input name=\"fase[]\" type=\"checkbox\" value=\"1\" />1
<input name=\"fase[]\" type=\"checkbox\" value=\"2\" />2
<input name=\"fase[]\" type=\"checkbox\" value=\"3\" />3
<input name=\"fase[]\" type=\"checkbox\" value=\"4\" />4
<input name=\"fase[]\" type=\"checkbox\" value=\"5\" />5
<input name=\"fase[]\" type=\"checkbox\" value=\"6\" />6
<span id=\"attachmentmarker\"></span>
</div>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"".DIM_MASSIMA."\" />
<input type=\"hidden\" name=\"ricid\" value=\"".$_GET['ricid']."\" />
<input type=\"submit\" value=\"invia\" />
</form>
</body>
</html>\n";
}
funzione addUpload() del file esterno.js
codice:
function addUpload(fileFieldName, checkFieldName){
nameFile=fileFieldName;
nameCheck = checkFieldName;
currentUploads++;
if (currentUploads>0)
document.getElementById('addupload').childNodes[0].data='Aggiungi file';
// First, clone the hidden attachment section
var newFields = document.getElementById('attachment').cloneNode(true);
newFields.id = '';
// Make the new attachments section visible
newFields.style.display = 'block';
// loop through tags in the new Attachment section
// and set ID and NAME properties
//
// NOTE: the control names for the Description Input
// field and the file input field are created
// by appending the currentUploads variable
// value to the nameFile and nameDesc values
// respectively
//
// In terms of Xaraya, this means you'll need to name your
// DD properties will need names like the following:
// "AttachmentDesc1"
// "AttachmentFile1"
// "AttachmentDesc2"
// "AttachmentFile2"
// "AttachmentDesc3"
// "AttachmentFile3"
// et cetera...
var newField = newFields.childNodes;
var newField2 = newFields.childNodes;
for (var i=0;i<newField.length;i++){
if (newField[i].name==nameFile){
newField[i].id=nameFile+currentUploads;
newField[i].name=nameFile+'[]';
//newField[i].name=nameFile+currentUploads;
}
}
for (var i=0;i<newField2.length;i++){
if (newField2[i].name==nameCheck){
newField2[i].id=nameCheck;
newField2[i].name=nameCheck+'[]';
//newField2[i].name=nameRadio+currentUploads;
}
}
// Insert our new Attachment section into the Attachments Div
// on the form...
var insertHere = document.getElementById('attachmentmarker');
insertHere.parentNode.insertBefore(newFields,insertHere);
}
magari per queste piccole modifiche mi danno la laurea ad honorem, c'è chi la prende "cantando" o correndo in moto