View Full Version : auto-select comboboxes

08-19-2005, 03:45 PM
i've searched everywhere but i cant quite find what im looking for i hope some1 here can help me...

ok so im making two forms, one that contains mostly comboboxes and loads all its contents from different tables in an SQL db and when the user submits it send the information to an independant table. Another form that also contains mostly comboboxes (and some comboboxes are the same as the first form, only like 2) is supposed to have an "optional" combobox that when the user selects an option, all the comboboxes that are the same as the first form automatically select the same option as they chose on the first form. this is used to save time, i really dont get it since it's only 2 comboboxes but my tutor sais it has to be that way so...

Anyway i know it's made with the "onchange event" on the optional combobox and that it's could be done with a javascript but problem is i dont know js. Also the way this works is that the user is given an Event ID on the first form so when they go to the second form they just select the event id on the optional combobox and the combos are filled.

So i hope some1 can point me the right way here, thanks in advance :)

08-19-2005, 03:56 PM
this really should be in the javascript forum since its a javascript question but anyway...
You need to make javascript arrays that contain all the information for all possbile event IDs... not sure why you've been told to do that, if an eventID has been assigned surely it would be easier for the page to automatically load up with those values selected, rather than the user having to remember the event id and pick the right one from the list but anyway..
so you'd need an array of possible event ids and then the 2 corresponding values then in the onchange part look up which items in the box should be selected.
As I said this should be in the js forum, I probably could write something but they're much better at it ;)

08-19-2005, 04:02 PM
i think they told me to do it that way because the second form is optional so when u click submit it doesnt redirect u to the second form it just submits the values on the first form but the second form contains some of the same elements so for users "save time" they made me do this :P. So ill try posting this in the js forum as well to see what they say thanks for ur reply :)

08-19-2005, 04:45 PM
someone told me that i could do this by using the get/post method, is this possible??? he said that on the onchange event you would have to make the page refresh and load the information into the comboboxes, im not sure if this works if someone knows how this could work plz tell me :D

08-19-2005, 04:49 PM
The point of using javascript is that it doesnt have to refresh the page so I'm not sure why you've been told that, unless its just a misunderstanding.
Ofcourse using a post or get from the previous form you could have the 2 boxes already filled in but thats not how you've described the scenario. To have the event fire when you select an item from a combobox then you need to have asp populate a javascript array with information that you will use to select the correct items in the other 2 combo boxes