Can I create a form on the fly?

Discussion in 'Javascript' started by kj, Aug 4, 2004.

  1. kj

    kj Guest

    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.
     
    kj, Aug 4, 2004
    #1
    1. Advertising

  2. kj

    Ivo Guest

    "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
     
    Ivo, Aug 4, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Spiewak

    Re: Create thumbnails on the fly

    Rick Spiewak, Jul 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    492
    David W. Simmonds
    Jul 25, 2003
  2. Cowboy \(Gregory A. Beamer\)

    Re: programatically create controls on the fly

    Cowboy \(Gregory A. Beamer\), Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    433
    Cowboy \(Gregory A. Beamer\)
    Jul 31, 2003
  3. James  Norton-Jones
    Replies:
    4
    Views:
    4,299
    James Zhuo
    Aug 25, 2003
  4. Brian

    Fly outmenu on the fly

    Brian, Apr 8, 2005, in forum: Javascript
    Replies:
    0
    Views:
    109
    Brian
    Apr 8, 2005
  5. Phil Powell

    I need to create a form on the fly

    Phil Powell, May 3, 2006, in forum: Javascript
    Replies:
    6
    Views:
    156
    Phil Powell
    May 4, 2006
Loading...

Share This Page