Shoutbox

JavaScript form constructor - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: JavaScript form constructor (/showthread.php?tid=62668)

JavaScript form constructor by Ezra on 07-06-2006 at 11:07 AM

I'm trying to create a form in JavaScript but I can't find the damn form constructor.

Does anyone here know how to create new form objects + hidden fields?

And I don't mean like document.write("<form>"); :P

TIA


RE: JavaScript form constructor by Veggie on 07-06-2006 at 11:24 AM

code:
var form = document.createElement('form');
form.setAttribute('method','post');
form.setAttribute('action','page.php');

var input = document.createElement('input');
input.setAttribute('name','pid');
input.setAttribute('type','hidden');
input.setAttribute('value',pid);

form.appendChild(input);
document.getElementsByTagName('body')[0].appendChild(form);

form.submit();