473,791 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic select boxes - simple question.

cy
Hi all,
I would appreciate it if anyone could point me on this.
My JSP page has 3 select boxes for states, counties and, cities and the
counties and cities should be populated once the user chooses a state and so
forth for the cities too.
I will need to get the data from an Oracle database.

Thanks so much in advance.
Jul 23 '05 #1
8 4279
cy wrote:
I would appreciate it if anyone could point me on this.
My JSP page has 3 select boxes for states, counties and, cities and
the counties and cities should be populated once the user chooses a
state and so forth for the cities too.
There are a number of solutions and approaches to implementing this. Search
the archives for this group for a lot of discussion about it.
If you are sure you want to implement this, you can use a library like mine
to get it done quickly and easily:
http://www.javascripttoolbox.com/dynamicoptionlist/
I will need to get the data from an Oracle database.


That is irrelevant in this context.
Where it comes from doesn't matter, and how you generate the HTML/JS doesn't
matter. As long as the correct javascript and html is generated and returned
to the browser, it will work.

--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
Jul 23 '05 #2
cy
Thanks Matt.
But, I cannot store all the values like Example1 shows. I need to get the
counties and cities from the database/file once a state is selected.

Any ideas?

Thanks.

"Matt Kruse" <ne********@mat tkruse.com> wrote in message
news:ca******** *@news1.newsguy .com...
cy wrote:
I would appreciate it if anyone could point me on this.
My JSP page has 3 select boxes for states, counties and, cities and
the counties and cities should be populated once the user chooses a
state and so forth for the cities too.
There are a number of solutions and approaches to implementing this.

Search the archives for this group for a lot of discussion about it.
If you are sure you want to implement this, you can use a library like mine to get it done quickly and easily:
http://www.javascripttoolbox.com/dynamicoptionlist/
I will need to get the data from an Oracle database.
That is irrelevant in this context.
Where it comes from doesn't matter, and how you generate the HTML/JS

doesn't matter. As long as the correct javascript and html is generated and returned to the browser, it will work.

--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/

Jul 23 '05 #3
"Matt Kruse" <ne********@mat tkruse.com> wrote in message
news:ca******** *@news1.newsguy .com...

you can use a library like mine
to get it done quickly and easily:
http://www.javascripttoolbox.com/dynamicoptionlist/


Just curious ... where is the code for the "DynamicOptionL ist()" function?
According to my understanding, this would be the constructor function of the
"DynamicOptionL ist" object.
Jul 23 '05 #4
cy
Thanks Dave,
but, the data for counties and cities should be obtained from a database or
file in my case. They are hard coded in Example1.

Any ideas?
Thanks.
"cy" <ja********@bls .gov> wrote in message
news:ca******** **@blsnews.bls. gov...
Hi all,
I would appreciate it if anyone could point me on this.
My JSP page has 3 select boxes for states, counties and, cities and the
counties and cities should be populated once the user chooses a state and so forth for the cities too.
I will need to get the data from an Oracle database.

Thanks so much in advance.

Jul 23 '05 #5
Amir wrote:
Just curious ... where is the code for the "DynamicOptionL ist()"
function? According to my understanding, this would be the
constructor function of the "DynamicOptionL ist" object.


In the js file...

// DynamicOptionLi st CONSTRUCTOR
function DynamicOptionLi st()

--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
Jul 23 '05 #6
cy wrote:
But, I cannot store all the values like Example1 shows.
Why not?
I need to get the counties and cities from the database/file
once a state is selected.


Then you should submit the form when a state is selected, do a query on the
server, and paint the appropriate select box when the html is returned. And
when you do that, it stops being a javascript question :)

--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
Jul 23 '05 #7
Matt Kruse wrote:
I need to get the counties and cities from the database/file
once a state is selected.

Then you should submit the form when a state is selected, do a query on the
server, and paint the appropriate select box when the html is returned. And
when you do that, it stops being a javascript question :)


Or, simply dynamically load the appropriate .js file as the result of a
query sent to the server. Keeps from reloading/refreshing the page but
can be slow at times....
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/
Jul 23 '05 #8
In article <ca**********@b lsnews.bls.gov> , ja********@bls. gov
enlightened us with...
Hi all,
I would appreciate it if anyone could point me on this.
My JSP page has 3 select boxes for states, counties and, cities and the
counties and cities should be populated once the user chooses a state and so
forth for the cities too.
I will need to get the data from an Oracle database.

Thanks so much in advance.


You can modify this javascript/CGI combo to instead have an onchange of
a select call a *servlet* (not a JSP page) that generates the
javascript. Note that this is merely an example of getting a client-side
event to trigger a server-side action. You need to make a javascript
that will change your options appropriately. I have an example of that
script, too, if you'd like.

This works only in DOM browsers and, for production, should be wrapped
in a check block to prevent bad things from happening on old browsers.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> Test server-side JS </title>
</head>

<body>
<script type="text/javascript">
function checkIt(variabl e, value)
{
var newScript = "cgi-bin/validateJS.cgi? "+variable+"="+ value;

var body = document.getEle mentsByTagName( 'body').item(0)
var scriptTag = document.getEle mentById('loadS cript');
if(scriptTag) body.removeChil d(scriptTag);
script = document.create Element('script ');
script.src = newScript;
script.type = 'text/javascript';
script.id = 'loadScript';
body.appendChil d(script)
}
</script>
<p>Test.</p>
<form id="f1" action="">
<input type="text" name="t1" id="t1" onChange="check It(this.name,
this.value)">
</body>
</html>

validateJS.cgi

#!/opt/x11r6/bin/perl
use CGI qw(:all);

my @valArray = split(/=/,$ENV{QUERY_STR ING});

print "Content-type: text/javascript\n\n" ;

# myPass is the password
$myPass = "foobar";

if ("$valArray[1]" eq "$myPass")
{
print "alert(\"Succes s!!\")";
}
else
{
print "alert(\"Failur e!!\")";
}

--
--
~kaeli~
God was my co-pilot... but then we crashed in the mountains
and I had to eat him.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #9

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

Similar topics

13
2898
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when the user selects shirts another combo box called 'size' would contain sizes in relation to shirts (ie. chest/neck size). the same would occur for trousers and hats. when the user selects an option in the garment combo box, the options available...
3
4319
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
1
17675
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
1
3341
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently overwhelmed by useless examples across the web on how to make "dynamic crosstab reports" without myself having a basic understanding about how to retrieve and assign recordsources, etc., from fields in a query to fields in the report. I see all these...
7
3391
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the database I am working on. IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL DROP TABLE REPORT_SELECTION
9
2905
by: Jimbo | last post by:
Hello, I have a user request to build a form in an Access database where the user can check off specific fields to pull in a query. For example, let's say I have 10 fields in a table. The user wants to be able to check off anywhere between 1 and all 10 fields in a form and have it return a select query with just the fields that were checked off. There are multiple users, so not all users will be checking off the same fields. Some...
19
3994
by: Alex | last post by:
Hello list This question has probably already been asked, but let me ask again I have a mysql database to which I connect with my php scripts. The database contains articles. Name, Unit_Price and Reference Now my client needs to order 5 items, click a button and a table with 5 lines and 3 columns appears (until now easy)
6
9435
by: robtyketto | last post by:
Greetings, Im a newbie to JSP/Javascript (unfortunalley). However I found enough example to create code that connects to my access db and populates two combo boxes. The selection of the first box is used to populate the second (cascading). See code below, apologies for the formatting as I wrote it in notepad. I am assuming the code runs through once and therefor combo box populated only once.
2
5037
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation is this, I have a page which uses multiple postbacks to generate a list of dynamic text boxes with appropriate labels. However, when I do the final postback to enter the values in the dynamic textboxes into the database the values seem to become...
0
9669
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
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
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
9993
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...
1
7537
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
6776
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();...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2913
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.