By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,500 Members | 2,520 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,500 IT Pros & Developers. It's quick & easy.

Can I create a form on the fly?

P: n/a
kj

Is it possible to create a form on the fly, by creating the form
and its elements, and adding them to the document somehow?

Thanks!

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ivo
"kj"wrote
Is it possible to create a form on the fly, by creating the form
and its elements, and adding them to the document somehow?


Depending on the capabilities of the browser, yes. Those supporting advanced
DOM methods will understand this:

{
var d=document;
var f=d.createElement('form');
var i=d.createElement('input');
var i2=i.cloneNode(false);
var br=d.createElement('br');
f.action='http://www.google.com/search';
f.method='get';
f.name='f';
i.type='text';
i.name='q';
i.value='';
i2.type='submit';
i2.value=' Search ';
f.appendChild(i);
f.appendChild(br);
f.appendChild(i2);
d.body.insertBefore(f,d.body.firstChild);
}

--Iv
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.