473,395 Members | 2,151 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,395 software developers and data experts.

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 4264
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********@mattkruse.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********@mattkruse.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 "DynamicOptionList()" function?
According to my understanding, this would be the constructor function of the
"DynamicOptionList" 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 "DynamicOptionList()"
function? According to my understanding, this would be the
constructor function of the "DynamicOptionList" object.


In the js file...

// DynamicOptionList CONSTRUCTOR
function DynamicOptionList()

--
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.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #8
In article <ca**********@blsnews.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(variable, value)
{
var newScript = "cgi-bin/validateJS.cgi?"+variable+"="+value;

var body = document.getElementsByTagName('body').item(0)
var scriptTag = document.getElementById('loadScript');
if(scriptTag) body.removeChild(scriptTag);
script = document.createElement('script');
script.src = newScript;
script.type = 'text/javascript';
script.id = 'loadScript';
body.appendChild(script)
}
</script>
<p>Test.</p>
<form id="f1" action="">
<input type="text" name="t1" id="t1" onChange="checkIt(this.name,
this.value)">
</body>
</html>

validateJS.cgi

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

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

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

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

if ("$valArray[1]" eq "$myPass")
{
print "alert(\"Success!!\")";
}
else
{
print "alert(\"Failure!!\")";
}

--
--
~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
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...
3
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
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...
1
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...
7
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...
9
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...
19
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...
6
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...
2
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...

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.