[Javascript] Database and SQL

Paul Novitski paul at juniperwebcraft.com
Tue Jan 30 10:59:35 CST 2007


At 1/30/2007 07:35 AM, Henrique Rennó wrote:
>There are two fields where will be put an 
>initial date and a final date which will be part of the SQL filter statement.
>
>There will be a dropdown box (select box) that 
>when the user clicks on it, he/she will select a 
>country's state where all the values (state's 
>names) are stored in a field from a table in the 
>Access database and will be loaded into the 
>select box being at most 30 values (I did it in 
>a form inside Access using VBA for the event 
>onClick and using a ADODB component to access 
>the table and get the values executing an SQL 
>statement constructed and stored in a String variable).
>
>Then the user will select an option from these 
>ones that were loaded into the select box 
>(he/she will select a state's name) and there 
>will be another select box that will show values 
>(cities' names) according to the one selected 
>inside the first select box where the first 
>select box with states works as a filter for the 
>second one with cities (again, using VBA I did 
>with no problems, just created the SQL statement and executed it).


Unless you have strict control over all the users 
of this application, you can't guarantee that 
everyone will have javascript enabled.  Therefore 
if you don't want the application to break for 
some users you should make sure it works when javascript is turned off.

A non-javascript version might look like this:

- download the page with states in a list
         - if it's a list of anchors, the user clicks on a state
         - if it's a select control, the user selects a state then submits form

- download the page with the cities for the 
selected state (and the states so the user can look at another state)
         - if it's a list of anchors, the user clicks on a city
         - if it's a select control, the user selects a city then submits form

- download the page with the results of the state-city query


When javascript is running, the process could like like this:

- download the page with states list and cities 
list, perhaps with the cities list hidden from view

- user selects a state

- javascript produces the resultant cities list, either:
         - by filtering a complete state-city list already in the page
or:
         - by requesting the cities list from the server using HttpXMLRequest

- user selects city

- javascript produces the results, either:
         - by filtering results from data already in the page
or:
         - by requesting the results from the server using HttpXMLRequest

Both of these processes (javascript and 
non-javascript) could occur with the same 
downloaded page.  When javascript is running, it 
dynamically hides & displays page elements that 
the non-javascript version needs to return to the server for.

Regards,

Paul
__________________________

Juniper Webcraft Ltd.
http://juniperwebcraft.com 




More information about the Javascript mailing list