var intCantItems = 0; var maxItems = 10; function addFiles() { if (intCantItems < (maxItems - 1)) { nDiv = document.createElement('div'); nDiv.className = 'archivo'; nDiv.id = 'file' + (++intCantItems); nCampo = document.createElement('input'); nCampo.name = 'fileNames[]'; nCampo.type = 'file'; nCampo.className='table_std'; a = document.createElement('a'); a.name = nDiv.id; a.href = '#'; a.onclick = delFiles; a.innerHTML = 'Delete'; nDiv.appendChild(nCampo); nDiv.appendChild(a); container = document.getElementById('Atachment'); container.appendChild(nDiv); if (intCantItems == (maxItems - 1)) { document.getElementById('addfile').style.display = 'none'; } } } function evento (evt) { return (!evt) ? event : evt; } function delFiles (evt){ evt = evento(evt); nCampo = rObj(evt); div = document.getElementById(nCampo.name); div.parentNode.removeChild(div); --intCantItems; document.getElementById('addfile').style.display = ''; return false; } function rObj (evt) { return evt.srcElement ? evt.srcElement : evt.target; }