473,385 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

accessing server database within javascript form

I have 3 dropdowns in my application. Based on the selections made in the
first two dropdowns, I need to pull out data from the database to set up the
corresponding menu for the third dropdown. How can I connect to the database
on the server after the first two dropdowns have been selected by the user
in order to be able to set up the third dropdown?

The first dropdown is states (8 in number for my application). The second is
counties (approx 80+ for each state). The data for the second dropdown is
calculated based on choice of the first dropdown. However since there are
only 8 states, i retrieve the data for 8 states and store it in arrays which
are then used for populating the second dropdown.

The problem is that now for the third dropdown there can be a very large
number of possible combinations of state and county. Retrieving this data
from the database beforehand might be overkill. I am looking at a dynamic
way to be able to retrieve this data on the fly. Is this possible at all?
Any hints/ideas would be appreciated...
Apr 24 '07 #1
5 3630
Navodit said the following on 4/24/2007 11:13 AM:
I have 3 dropdowns in my application. Based on the selections made in the
first two dropdowns, I need to pull out data from the database to set up the
corresponding menu for the third dropdown. How can I connect to the database
on the server after the first two dropdowns have been selected by the user
in order to be able to set up the third dropdown?
http://jibbering.com/faq/index.html#FAQ4_34
http://jibbering.com/faq/index.html#FAQ4_44

Although personally, I would load the new data in a .js file by
dynamically inserting a script element in the page. Get my data back as
JSON Data and off to the races.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 24 '07 #2

"Randy Webb" <Hi************@aol.comwrote in message
news:AK********************@giganews.com...
Navodit said the following on 4/24/2007 11:13 AM:
>I have 3 dropdowns in my application. Based on the selections made in the
first two dropdowns, I need to pull out data from the database to set up
the corresponding menu for the third dropdown. How can I connect to the
database on the server after the first two dropdowns have been selected
by the user in order to be able to set up the third dropdown?

http://jibbering.com/faq/index.html#FAQ4_34
http://jibbering.com/faq/index.html#FAQ4_44

Although personally, I would load the new data in a .js file by
dynamically inserting a script element in the page. Get my data back as
JSON Data and off to the races.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/
I am new to Javascript and am not quite sure how to use ajax here. Should I
create a xmlhttprequest object which invokes a .asp file which in turn
queries the database. And then retrieve the data from the xmlhttprequest
object? Would there be any sample scripts available which might give me some
idea how to code such a script? Any help would be appreciated. thanks..
Apr 25 '07 #3
Navodit said the following on 4/25/2007 4:48 PM:
"Randy Webb" <Hi************@aol.comwrote in message
news:AK********************@giganews.com...
>Navodit said the following on 4/24/2007 11:13 AM:
>>I have 3 dropdowns in my application. Based on the selections made in the
first two dropdowns, I need to pull out data from the database to set up
the corresponding menu for the third dropdown. How can I connect to the
database on the server after the first two dropdowns have been selected
by the user in order to be able to set up the third dropdown?
http://jibbering.com/faq/index.html#FAQ4_34
http://jibbering.com/faq/index.html#FAQ4_44

Although personally, I would load the new data in a .js file by
dynamically inserting a script element in the page. Get my data back as
JSON Data and off to the races.
I am new to Javascript and am not quite sure how to use ajax here. Should I
create a xmlhttprequest object which invokes a .asp file which in turn
queries the database. And then retrieve the data from the xmlhttprequest
object?
Yes, that is how you would do it.
Would there be any sample scripts available which might give me some
idea how to code such a script? Any help would be appreciated. thanks..
<URL: http://www.ajaxtoolbox.comwould be about the best place to
start. Ready made library that is pretty simple to figure out.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 25 '07 #4
Yup, it's called AJAX. It uses the javascript xmlHttpRequest object
to pull data from the server after the page has loaded. It's used all
over the web, most notably with Gmail.

Here's one example that I quickly found on a PHP forum:
http://www.webmasterworld.com/php/3308690.htm

but there are literally thousands of examples on the web:
http://www.google.com/search?q=ajax
Apr 25 '07 #5
kday said the following on 4/25/2007 6:38 PM:
Yup, it's called AJAX.
"Yup"? But, it is called "Quoting what you are replying to".
It uses the javascript xmlHttpRequest object
to pull data from the server after the page has loaded. It's used all
over the web, most notably with Gmail.
Somehow, I doubt Hmail is the "most notable" use of AJAX.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 25 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: J. J. Cale | last post by:
I want to access the DOM. Can something like this be done with PHP or a combination of PHP/JAVASCRIPT? not tested! <html><head><title>DOM test</title> <?php $inFileName = 'test.js'; $outFileName...
6
by: Andy Wawa | last post by:
Hi, on a simple HTML (not an ASP!)-Site I try to connect to a sql server (MS): <html> <title>Test</title> <head> <script language="javascript"> <!-- Function showForm(){
3
by: prodirect | last post by:
Hi all, I hope someone can help me. I've recently created a database and wanted to put it up on an ftp sight so that multiple people could access the same tables at the same time from different...
1
by: Suhail A, Salman | last post by:
Dear All, I placed a HtmlSelect control on a web page and set it to "Run at Server", the objective of this HtmlSelect control is that the client adds all his accounts to a text box, and...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
0
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
3
by: BAnderton | last post by:
Hello all, Question: Is there any way to access a javascript variable from within psp code? I'm aware of how to do the reverse of this (js_var='<%=psp_var%>'). Here's a non-working...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.