First my english sucks, but I don't think you all can read dutch
OK, i'm busy making a site for a audiovisual company and i'm stuck at the CMS system by adding pictures to a project page.
Adding one single photo isn't the problem but I want a button to add a new file input field and insert that second (or thirth, fourth etc etc) into a new row in the database....
The script that i'm using right now, clones the input field but doesn't "activates" it.... You can't select a file....
The javascript:
Code:
function clone() {
var parent=document.getElementById('naw0');
var cloned=parent.cloneNode(true);
// unique id
var aNaam=document.getElementsByName('imgfile[]');
var num=aNaam.length;
cloned.id='naw'+num;
//insert after last pair
parent.parentNode.insertBefore(cloned, document.getElementById('naw'+(num-1)).nextSibling);
//clear inputs
var aInput=cloned.parentNode.getElementsByTagName("file");
aInput[aInput.length-3].value='';
}
cloned.id='naw'+num;
var newValue = 'imgfile'+num;
cloned.getElementsByTagName('label')[0].setAttribute('for', newValue);
cloned.getElementsByTagName('input')[0].id = newValue;
//insert after last pair
At least 98% of internet users' DNA is identical to that of chimpanzees
It's still not active, when I add a new input field.....
Code:
function clone() {
var parent=document.getElementById('naw0');
var cloned=parent.cloneNode(true);
// unique id
var aNaam=document.getElementsByName('imgfile[]');
var num=aNaam.length;
cloned.id='naw'+num;
//id must be unique
var newValue = 'imgfile'+num;
cloned.getElementsByTagName('label')[0].setAttribute('for', newValue);
cloned.getElementsByTagName('input')[0].id = newValue;
//insert after last pair
parent.parentNode.insertBefore(cloned, document.getElementById('naw'+(num-1)).nextSibling);
//clear inputs
var aInput=cloned.parentNode.getElementsByTagName("file");
aInput[aInput.length-3].value='';
}
you have to physically click on a file upload to fill it with data.
this is a browser-enforced security policy.
there is no way to clone a filled input.
even if the duped .value looks like it holds the file, there won't be any actual data.
Bookmarks