Can I create a form on the fly?

K

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
 
I

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top