sjohnson
08-06-2004, 01:36 PM
How can I update a listbox without refreshing the whole page.
Example:
Select Country in box1, query db and populate box2 with states without refreshing the page.
Thanks for all the help!
Terry
08-06-2004, 01:49 PM
I'm pretty certain you'll need javascript to this:
http://developer.irt.org/script/script.htm
You're talking about client-side script... I'm not saying it isn't possible to query a database (assuming it's a server database, not a client database like MS Access) using client-side script, I'm just saying I doubt that's what you'd want!
In order to access the database from client-side script you'd have to either use ActiveX (IE only, you're using VBS so no worries there) or create a Java applet that connects to the database (which would have to be signed in order to do that.) Now, the real issue is, do you really want everyone downloading that page to have access to your database? If you have set reasonable security restrictions on the database, users have just gained access to read from it by downloading your page... don't be fooled by the applet approach either, Java class files can be decompiled (or simply viewed through a hex editor and looked over for the connection string.)
Now that we have all of that past us, there really are only two viable remaining solutions:
1) Transmit every possible outcome for 'box2' to the client by placing it in client-side variables (yes, preferebly JavaScript, as JS is supported by browsers other than IE) which would most likely mean the client has to download much more information than needed, thereby placing a possible burden on your server, or
2) Do like everyone else in such a situation and use server-side scripting. To measure whether or not this would be worse for the server take into account the page's size, assume that the page must be downloaded a minimum of two times, or the page and all the variables belonging to 'box2' must be downloaded.
If you do decide to use the first solution, you should still have the second solution available to clients that don't have JavaScript enabled on their browser or are using too-ancient-a-browser for your script to work.
Just to clarify, you can of course do the first solution in VBScript, but you'll have to bear the consequences.
vBulletin v3.0.3, Copyright ©2000-2012, Jelsoft Enterprises Ltd.