nevets2001uk
IS-IT--Management
I'm currently working on a new application and it has brought up a question of the best method for dealing with a page of many dropdowns, each of affecting the items in another. I'll try to explain the situation a bit.
I have a page with 4 dropdown lists which are all at populated from an SQL database. The user first selects a name from a list populated on page load. Another drop down allows the user to select a device type (i.e. computer, printer, scanner). When either of these are changed the Devices dropdown updates from the DB with a list of all the devices of the chosen type for the chosen user. Choosing a different Device Type also updates the items in a category dropdown.
Hope that makes some sense!
What I'd like to know is, is there a best practice for coding this style of page. At the moment it works but I'm not sure the code is that optimised. For example choosing a new user causes the app to have to look the username up in the database just to get their userID. I don’t really want to do this as it has already looked to that table in the db when populating the list in the first place. But how can I know what userID goes with the user in the list? The app then looks that up in the DeviceLine table to find all devices for that user pulling out their DeviceID's. Then it looks to the DeviceTable to get the actual device information based on the DeviceID.
This is a lot of calls to the database. The main problem I have with this method is populating the users from the database and then looking back to it to pull out the userID. Is there a way to associate the id with each entry in the dropdownbox without displaying it? I've considered populating arrays for all the data on page load but is this a good idea as much of the data won't be needed and therefore I'm wasting time pulling it all from the database in advance.
I know this is probably unclear as it's a fairly open-ended and complex question. All ideas welcomed.
Cheers,
Steve G (MCP)
I have a page with 4 dropdown lists which are all at populated from an SQL database. The user first selects a name from a list populated on page load. Another drop down allows the user to select a device type (i.e. computer, printer, scanner). When either of these are changed the Devices dropdown updates from the DB with a list of all the devices of the chosen type for the chosen user. Choosing a different Device Type also updates the items in a category dropdown.
Hope that makes some sense!
What I'd like to know is, is there a best practice for coding this style of page. At the moment it works but I'm not sure the code is that optimised. For example choosing a new user causes the app to have to look the username up in the database just to get their userID. I don’t really want to do this as it has already looked to that table in the db when populating the list in the first place. But how can I know what userID goes with the user in the list? The app then looks that up in the DeviceLine table to find all devices for that user pulling out their DeviceID's. Then it looks to the DeviceTable to get the actual device information based on the DeviceID.
This is a lot of calls to the database. The main problem I have with this method is populating the users from the database and then looking back to it to pull out the userID. Is there a way to associate the id with each entry in the dropdownbox without displaying it? I've considered populating arrays for all the data on page load but is this a good idea as much of the data won't be needed and therefore I'm wasting time pulling it all from the database in advance.
I know this is probably unclear as it's a fairly open-ended and complex question. All ideas welcomed.
Cheers,
Steve G (MCP)