472,353 Members | 2,223 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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 12410

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sue | last post by:
Hello! I am back with another question. Remember I am a new JavaScript student and I am aware that this code does not check for all the...
1
by: SABmore | last post by:
I have the following code that populates 3 independent drop-down boxes with data from arrays. From there the user can select a value from a...
5
by: Matt | last post by:
I want to write a generic clearForm function to clear the form when the user click CLEAR button. Here's my attempts, because I want to take care...
1
by: SAN CAZIANO | last post by:
how can clear an html SELECT and next insert in it all the elements of an array () I try this but seems doesn't works. function...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the...
3
by: Robert Kilroy | last post by:
Greetings, I've been working on this for a few hours now. It seems to be a pretty simple task but I keep running into " has no properties". I...
3
by: Italio Novuas | last post by:
Hi all, let me begin by saying that I *ALMOST* have this complete! What I'm trying to do is make it so my text area shows the innerHTML of any...
1
by: vraamu | last post by:
here in this option transfer code.after transfering data from available _services multiple box to assigned_services multiple box i am unable to get...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.