Can I create a form on the fly?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kj

    Can I create a form on the fly?




    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.
  • Ivo

    #2
    Re: Can I create a form on the fly?

    "kj"wrote
    [color=blue]
    > Is it possible to create a form on the fly, by creating the form
    > and its elements, and adding them to the document somehow?[/color]

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

    {
    var d=document;
    var f=d.createEleme nt('form');
    var i=d.createEleme nt('input');
    var i2=i.cloneNode( false);
    var br=d.createElem ent('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(b r);
    f.appendChild(i 2);
    d.body.insertBe fore(f,d.body.f irstChild);
    }

    --Iv


    Comment

    Working...