Common problem... How do you deal with it?

S

Seibar

Assume you have a page with the following drop down select lists

List_Of_States (Contains 50 States)
List_Of_Counties (Contains a list of counties in the selected state)
List_Of_Cities (Contains a list of cities/towns in the selected
county)

The list of states is static.
The list of counties would be fairly small (~20 counties per state = ~1000
counties)
This would result in~15K-20K of text/XML which could be stored in a
hidden field on the page.
Note: I wouldn't do that, but the question is hypothetical.
The list of cities is large and a filter at the server would be required.

Object of the game (using the above scenario):
When the user selects a state the applet would read the HTML stream, search
the hidden text or XML data for the counties in the selected state.
It would replace (for example)
<SELECT NAME="List_Of_Counties" >
<OPTION > ADAMS
<OPTION> BAKER
<OPTION> KING
<OPTION> LEWIS
</SELECT>

with

<SELECT NAME="List_Of_Counties" >
<OPTION > KITSAP
<OPTION> MASON
<OPTION> PIERCE
<OPTION> ZULU
</SELECT>

And then force the browser to render the resultant stream.

A similar function would be needed to replace <SELECT
NAME="List_Of_Cities">,
but it would get its list info from a database on the server.
Obviously, I could do this via ASP, but that means doing a
postback every time the user clicks a dropdown. More importantly, there
could in principle be any number of lists/data driven items on a page and I
might only want to reload one of them.
Is there a java applet (or a commercial product) that can do what I want to
do? I'm an
experienced programmer, but I've never jumped into the java pool. The
state/county/city page discussed above is not important, nor am I building
such a page. What I'm looking for is a general purpose applet to
replace a control on a page. Any advice would be appreciated. email:
(e-mail address removed)
 
M

Mark Voorberg

I've seen this done three ways... that readily come to mind.

1) Put all the values in a Javascript array and load the select lists as the
user changes the "state" select list. This works great when the dependant
lists are of reasonable size and you don't mind sending them down with each
page.

2) Post the whole page back to the server when the suer changes the "state"
select list & send it back with a new list of counties.

3) When the user chnages the "state", open a second, small popup window that
hits the server with the selected sate and get the list of counties that
goes with it. Then using javascript, clear and reload the counties list.
I've used this one personally & it works well for a couple reasons. There's
no need to download all the select list options as there could be very many
especially if the dependand lists are nested. Secondly, you don't need to
manage posting the entire page back to the server.

As far as using an applet to do this, I'd be very careful. Applet support
is sketchy at best & will result in increased support costs.

Cheers,
Mark Voorberg
www.ObjectClarity.com
 
S

Seibar

Thanks, Mark. I appreciate your response, but I'm really searching for a way
to manipulate the browser's innerHTML property. One would think, perhaps
naively, that you could parse a text stream that begins with <HTML> and ends
with </HTML>, find (e.g.) <SELECT NAME="List_Of_Counties" > and its
terminating </SELECT> and replace the text between the select tags with a
new set of options. All the browser does is render the text, and it seems to
me there ought to be a general purpose way to modify the innerHTML and
outerHTML properties of an instance of a browser object. If no such thing
exists, it might be profitable to create one myself. Anyway, thanks again
for your response.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top