
12-12-2007, 09:49
|
|
|
|
חבר מתאריך: 15.08.06
הודעות: 1,561
|
|
מסיבה בלתי מוסברת, היו לי 10 דקות פנויות אז עשיתי לך את זה:
קוד:
var open = 1;
var max = 5;
function addfileup()
{
if (open <= max)
{
oDiv = document.createElement("<div id=\"upfile" + open.toString() + "\">");
oDiv.style.display = 'inline';
oSpan = document.createElement("span");
oSpan.className = 'uptexts';
oSpan.innerText = 'בחר קובץ: ';
oInput = document.createElement("<input type=\"file\" size=\"45\" />");
oBtn = document.createElement("<input type=\"button\" value=\"הסר\" onclick=\"delfileup(" + open.toString() + ")\" />");
oSpan.appendChild(oInput);
oSpan.appendChild(oBtn);
oDiv.appendChild(oSpan);
document.getElementById('uploads').appendChild(oDi v);
++open;
}
else alert("out of space");
}
function delfileup(id)
{
if (id < open) {
alert ("error?");
return;
}
curFile = document.getElementById('upfile' + id.toString());
document.getElementById('uploads').removeChild(cur File);
++max;
}
אתה צריך למחוק את כל הUPLOADים שעשית שם ולשים במקום זה:
קוד:
<div id="uploads"></div>
לפני שאתה מגיב, לא יצא לי לנסות את זה בכלל ואין לי מושג אם זה עובד, אבל הרעיון אמור להיות ברור - אתה יוצר כל פעם שדה כזה דינמי ומוחק אותו כשאתה עושה הסר. אני נעזרתי בעזרה של MSDN באינטרנט (חפש למשל appendChild בגוגל).
אגב, בשיטה הקודמת, היית חייב לשנות את הvalue של הקובץ כדי שאם אתה מסיר אותו שהוא לא יעלה אותו עדיין
|