javascript problem - firefox

advertisements

Hi all Why this piece of javascript code doesn't work on firefox

var nfiles = 1;
function Expand(){
nfiles++
var adh = '<input type="file" name="File '+nfiles+'">';
files.insertAdjacentHTML('BeforeEnd',adh);
return false;
};


It looks like you have no semi-colon after your variable.

Shown below is a working Expand function for all browsers including Firefox.

Reference: jsFiddle.

function Expand() {
    nfiles++;
    var files = document.getElementById('test');
    var adh = '<input type="file" name="File ' + nfiles + '">';
    files.insertAdjacentHTML('afterend', adh);
    return false;
}