473,796 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3659
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.javas cript 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******** ************@gi ganews.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.javas cript 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******** ************@gi ganews.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.javas cript 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.javas cript 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
2307
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 = 'jk.js'; function doIt() { $dd = getElementById('first'); $dd.innerText=$outFileName; }
6
23515
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
4322
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 geographical locations. I have been completely unsucessful in acheiving this goal so far however. Things I have tried: Create a shortcut to ftp sight via browser then tried to map local drive to
1
2274
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 because this is a client side operation(no server intervention is required), I wrote the JavaScript below to add account number entered in a text box to the list control, this works fine, the client can
1
3142
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 elements and would like to seek a solution for this. I had looked through several articles for accessing programatically-created dynamic elements such as: 1)
0
12089
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 likelihood of CRM success from less than 20 percent to 60 percent. WHITEPAPER :
0
2810
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 chkAll. I simply want to have chkAll be checked if every item in the repeater has its checkbox checked. In the code behind page, I can access the checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
7
3821
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 database search that I am unable to figure out how to access. (The search is implemented in Php/MySQL.) The user enters search values for: name, address1, city, .... etc., ..... and for each of these they also select whether the search should...
3
2423
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 example of what I'm trying to do:
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.