javascript - Mozilla form.submit() not working -
i creating dynamic form using following code,
function createform() { var f = document.createelement("form"); f.setattribute('method',"post"); f.setattribute('action',"./upload"); f.setattribute('name',"initiateform"); f.acceptcharset="utf-8"; var name = document.createelement("input"); name.setattribute('type',"text"); name.setattribute('name',"projectname"); name.setattribute('value',"saket"); f.appendchild(name); f.submit(); }
but in mozilla nothing happens code works expected ( in chrome). code being called function invoked button on click event. after executing code returning false.
please me out. in advance :-)
you need append new created form document, because not there on page load.
try this:
function createform() { var f = document.createelement("form"); f.setattribute('method',"post"); f.setattribute('action',"./upload"); f.setattribute('name',"initiateform"); f.acceptcharset="utf-8"; var name = document.createelement("input"); name.setattribute('type',"text"); name.setattribute('name',"projectname"); name.setattribute('value',"saket"); f.appendchild(name); document.body.appendchild(f); // added f.submit(); }
Comments
Post a Comment