Refresh values in Select List based onChange of a Dropdown box
I am trying to learn and use good DHTML concepts and code (assuming they are needed). My current issue concerns how to handle this situation.
I have a Select List box which displays values based on what value is selected in a dropdown list. For example, my dropdown list contains a class name, and the Select list contains all of the students who are registered for that class.
So what I would like to occur, is when the user changes the class from the dropdown box, the Select List is re-created displaying the students who are enrolled in that class.
I thought I could do this without having to reload the page (with DHTML) but here is my problem.
I use the ASP code to select the students for the class. When the page initially loads, I just take the primary key from the 1st class and display all of the students for that class. Now once the page loads, I can not re-query unless I reload the page correct?
I guess I saw a few ways I could handle this…
1) I could learn AJAX (make an ASP call and then rebuild the list box using DHTML)… do you think this is possible?
3) I guess I could also just forget about the DHTML and place the class id value in session and just reload the page.
I was hoping someone could advise me on the best way to handle this situation. Maybe I have not considered the correct solution.
Yep those are your options in a nutshell. All are possible and viable depending on a few conditions.
To determine the right option, consider...
- how often will that page be visited? If lots and lots, a client-side solution would relieve load from the server.
- how many students are we talking about? If thousands, then loading that array every page load would take a long time.