Creating a html drop-down list dynamically

G

Gurry

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
 
K

kaeli

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/

--
 
R

Richard Cornford

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.
 
K

kaeli

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


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.

--
 

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

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top