Click to See Complete Forum and Search --> : Select constructor


cmyers
01-28-2003, 10:25 AM
Is is possible to create a prototype with a select constructor like:

function insert(CSelect){
var select = new Select

}


And then add the options by calling ...

Option.insert(CSelect)

Cathy :confused:

Dan Drillich
01-28-2003, 10:58 AM
Cathy,

Here is an example of dynamically adding an option to a select list.
Does it help?

Cheers,
Dan


<SCRIPT language="JavaScript">
<!--

var excite = new Option("Excite","http://www.excite.com",false,false);

//-->
</SCRIPT>

Then function called from form:

<FORM name="form1">
<SELECT name="menu1">
<OPTION selected>-- select --</OPTION>
<OPTION value="http://google.com">Google</OPTION>
</SELECT>

<SCRIPT language="JavaScript">

var engines = document.form1.menu1;
engines.options[engines.options.length] = excite;

</SCRIPT>


</FORM>

cmyers
01-28-2003, 11:23 AM
Dan,
I saw how to dynamically add an option via the option constructor like what you did. But this is more along the lines of a dynamic select. Do you know if this is possible?

Cathy