469,365 Members | 1,789 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,365 developers. It's quick & easy.

code to clear all select options

I am very new to java script and I am trying to be able to have two
select boxes. One that has states and one that has cities. On the
change or pick of the state then the cities in my data base are they
loaded. I do this using sajax (basically using java script to go back
to the server with out a page refresh). Well my problem comes after
that when I click on a state and then say I picked the wrong state and
clicked on another state in my cities select box sometimes has the
cities of the previous state. This happens because I have the options
loaded into the select box by java script but I was wonder if there was
a away I could totally clear out the select cites box before I add the
news cities. If I cant I guess I just am going to do a disable on the
select box.

Oct 7 '06 #1
1 12306

ja*********@gmail.com wrote:
I am very new to java script and I am trying to be able to have two
select boxes. One that has states and one that has cities. On the
change or pick of the state then the cities in my data base are they
loaded. I do this using sajax (basically using java script to go back
to the server with out a page refresh). Well my problem comes after
that when I click on a state and then say I picked the wrong state and
clicked on another state in my cities select box sometimes has the
cities of the previous state. This happens because I have the options
loaded into the select box by java script but I was wonder if there was
a away I could totally clear out the select cites box before I add the
news cities.
You can remove all the options by settting the select's length property
to zero (0). Note that a select element with no options is invalid, so
clear them out just before you put some back.
--
Rob

Oct 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by rked | last post: by
3 posts views Thread by Italio Novuas | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.