By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

dynamic option list

P: n/a
I have generated a dynamic option list from an array using
elementCreate("OPTION")

I now wish to get an event to replace this list with a new one, but of
course currently, it simply adds them on to the end of the list.

Can I Delete or overwrite the options and if so by what method?

Many thanks

Phil
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try document.YourFormName.YourSelectName.options.lengt h=0;

John

"Philip WATTS" <PR*****@syringa.freeserve.co.uk> wrote in message
news:cb**********@newsg4.svr.pol.co.uk...
I have generated a dynamic option list from an array using
elementCreate("OPTION")

I now wish to get an event to replace this list with a new one, but of
course currently, it simply adds them on to the end of the list.

Can I Delete or overwrite the options and if so by what method?

Many thanks

Phil

Jul 23 '05 #2

P: n/a
Philip WATTS wrote:
I have generated a dynamic option list from an array using
elementCreate("OPTION")
This is not a built-in method of any widespread DOM.
I now wish to get an event to replace this list with a new one,
You should get informed about what an event is. Probably you are
looking for event listener code triggered by an intrinsic event
handler.
but of course currently, it simply adds them on to the end of the list.

Can I Delete or overwrite the options and if so by what method?


Try this:

<form action="...">
<select name="mySelect">
<option value="foo">bar</option>
...
</select>
<input
type="button"
value="Replace"
onclick="this.form.elements['mySelect'].options[0].text = 'foobar';">
<input
type="button"
value="Clear"
onclick="this.form.elements['mySelect'].options.length = 0;">
...
</form>
PointedEars
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.