Creating a html drop-down list dynamically

Discussion in 'Javascript' started by Gurry, Dec 18, 2003.

  1. Gurry

    Gurry Guest

    Hi there

    I would like to write a javascript function that creates a drop-down
    list dynamically. I read on the docs that most HTML controls can not
    be created on run-time. what kind of work-arounds do you use in this
    case? maybe DHTML?
    do you have any example ?
    Javascript allows you to create the options of the drop-down list
    dynamically but not the drop-down list itself, I believe.
    Actually the same question goes for any other HTML control.

    any reference, example, link, suggestion greatly appretiated.

    Thanks a lot

    Gurry
     
    Gurry, Dec 18, 2003
    #1
    1. Advertising

  2. Gurry

    kaeli Guest

    In article <>,
    enlightened us with...
    > Hi there
    >
    > I would like to write a javascript function that creates a drop-down
    > list dynamically. I read on the docs that most HTML controls can not
    > be created on run-time. what kind of work-arounds do you use in this
    > case? maybe DHTML?
    > do you have any example ?
    > Javascript allows you to create the options of the drop-down list
    > dynamically but not the drop-down list itself, I believe.
    > Actually the same question goes for any other HTML control.
    >
    > any reference, example, link, suggestion greatly appretiated.
    >


    Sure you can, for modern browsers that support createElement.
    http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/create
    element.asp

    For full dhtml reference for IE, see
    http://msdn.microsoft.com/library/default.asp?
    url=/workshop/author/dhtml/reference/methods.asp

    Note that not all browsers support createElement or all of MSIE DHTML.
    For the second most popular browser, see NN/Mozilla docs here.
    http://www.mozilla.org/docs/web-developer/

    --
    --
    ~kaeli~
    A man's home is his castle..., in a manor of speaking.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Dec 18, 2003
    #2
    1. Advertising

  3. kaeli wrote on 18 Dec 2003 at Thu, 18 Dec 2003 16:10:37 GMT:

    > Sure you can, for modern browsers that support createElement.
    > http://msdn.microsoft.com/workshop/author/dhtml/reference/methods
    > /create element.asp


    The createElement method is actually part of W3C's DOM
    specification. Modern versions of all browsers that support DOM,
    including IE, Mozilla, Netscape and Opera, should implement
    document.createElement().

    Mike

    --
    Michael Winter
    d (replace ".invalid" with ".uk")
     
    Michael Winter, Dec 18, 2003
    #3
  4. "Michael Winter" <> wrote in message
    news:Xns9455EDB42A0FDMWinterBlueyonder@193.38.113.46...
    <snip>
    >>Sure you can, for modern browsers that support createElement.
    >>http://msdn.microsoft.com/workshop/author/dhtml/reference/
    >>methods/create element.asp

    >
    >The createElement method is actually part of W3C's DOM
    >specification. Modern versions of all browsers that
    >support DOM, including IE, Mozilla, Netscape and Opera,
    >should implement document.createElement().


    A problem arises with less dynamic browsers, they can reasonably
    implement the official DOM structure (childNodes, parentNode and so on)
    convenience properties and element/collection retrieval methods making
    access and navigation of a standardised DOM practical but if they are
    not dynamic enough to reflect changes in the DOM structure into changes
    in the displayed page it might reasonably be argued that not
    implementing createElement, replaceChild and so on is a good way of
    advertising the limited capabilities of the browser to the script
    author. These days the less dynamic browsers tend to be found on
    smaller devices but the modern ones do seem to go as far as practical
    towards implementing the W3C DOM, they just don't include the more
    dynamic methods.

    Richard.
     
    Richard Cornford, Dec 19, 2003
    #4
  5. Gurry

    kaeli Guest

    In article <Xns9455EDB42A0FDMWinterBlueyonder@193.38.113.46>,
    d enlightened us with...
    > kaeli wrote on 18 Dec 2003 at Thu, 18 Dec 2003 16:10:37 GMT:
    >
    > > Sure you can, for modern browsers that support createElement.
    > > http://msdn.microsoft.com/workshop/author/dhtml/reference/methods
    > > /create element.asp

    >
    > The createElement method is actually part of W3C's DOM
    > specification. Modern versions of all browsers that support DOM,
    > including IE, Mozilla, Netscape and Opera, should implement
    > document.createElement().
    >


    I know. If you pointed that out because of the link to MS, I linked
    there because I like the docs. The MS docs are my fav source of info for
    the "new" kinds of DHTML because they have rather nice examples and the
    properties and methods are easy to find. It's searchable, too.

    If anyone has Mozilla/Netscape docs set up this nice, I'd love a link.
    The source I have does the job as far as making sure something works in
    NN, but isn't nearly as nice as the MS site.

    --
    --
    ~kaeli~
    Do cemetery workers prefer the graveyard shift?
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Dec 19, 2003
    #5
    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. SirPoonga
    Replies:
    2
    Views:
    819
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,074
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    550
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    318
  5. Replies:
    3
    Views:
    323
Loading...

Share This Page