2 dropdownlists

B

Bart Schelkens

Hi,

I have a webpage that contains 2 dropdownlists.

One is displaying Categories and the other is displaying sub-categories.
When I click on a categorie in the first dropdownlist, I want the second
list to display
the sub-categories for the selected category.

I tried it using the SelectedIndexChanged but this doesn't fire until a
submit of the page. Is there a way to have the desired effect whitout having
to perform a submit ?

Thanks.
 
M

Mark Rae

Is there a way to have the desired effect whitout having to perform a
submit ?

Yes, but I'm going to get flamed for suggesting it :)

But before I do, you must have a REALLY good reason for not performing a
submit, because that is by far the best way to achieve what you want.

However, if you really don't want to submit, and the datasets in question
are relatively small, you could create a JavaScript client-side array in the
<HEAD> of your page which contains all of the records in the related combo.
Then, when the user selects a different option in the first combo, you call
a client-side JavaScript function which clears the options from the second
combo and repopulates it with only thos options which relate to the
selection in the first combo.

This is not a good idea for several reasons:

1) The array is likely to be large, which will slow the initial load of your
page.

2) If a new option is added to the database, it will not be picked up until
the page actually is refreshed.

Don't do it unless there is a compelling reason to do so...
 
B

Bart Schelkens

Mark,

the problem was that it only worked when i pushed a submit-button.
And at some point during the refresh I lost the data that was in the
dropdownlists.

With the AutoPostBack it doesn't have that effect.

Maybe I wasn't clear in my question. If so, sorry for that.
 
M

Mark Rae

the problem was that it only worked when i pushed a submit-button.
And at some point during the refresh I lost the data that was in the
dropdownlists.

With the AutoPostBack it doesn't have that effect.

Maybe I wasn't clear in my question. If so, sorry for that.

That's no problem.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top