I just finished implementing something exactly like this, except I had three
levels of selection. It is important to understand what is happening on the
server and what is happening on the client. I decided to use JavaScript on
the client to fill the listboxes, so there would not be a round-trip and
page refresh every time the user changed selections. What this means is
that you have to send down all possible lists of list items ("Options" in
javascript) to the client when the page is first served. Then you can hook
the onChange event to a js function that fills the second list with the
appropriate items when the first list is tickled. Because I was dealing
with a what could potentially be a large amount of data, I implemented a
cache of the result set(s) on the server side, so that every time a user
requested the page, I didn't have to hit the database. This worked just
fine in my case because the items I am retrieving are not changed very
often.
I used arrays of arrays in javascript to store the lists on the client, so
the generated code looks something like this:
<script language=javascript>
var allLists = new Array();
var valuesA1 = new Array();
valuesA1[0] = new Option("A1name0, A1value0");
valuesA1[1] = new Option("A1name1, A1value1");
valuesA1[2] = new Option("A1name2, A1value2");
allLists["A1"] = valuesA1;
var valuesA2 = new Array();
valuesA2[0] = new Option("A2name0, A2value0");
valuesA2[1] = new Option("A2name1, A2value1");
valuesA2[2] = new Option("A2name2, A2value2");
allLists["A2"] = valuesA2;
function fillB()
{
// Iterate thru listA, figure out which options are selected
// For each selected item, use the options value as an index
into the allLists Array
// Fill listB with the options in the specified array (hint:
create a new Option object instead of just assigning the select objects
options to the ones in your array, if you don't Netscape 4.7 will crash)
}
</script>
<select name=listA onChange="fillB">
<option value=A1>A1
<optoin value=A2>A2
</select>
<select name=listB>
<option>[Select a value from listA]
</select>
You'll need to write the server-side code to generate the above option
arrays, but that's just basic JSP stuff.
Have fun,
Jeff
> -----Original Message-----
> From: Mukka, Srikanth [mailto:[EMAIL PROTECTED]]
> Sent: Monday, October 30, 2000 10:47 AM
> To: [EMAIL PROTECTED]
> Subject: Re: populate list item
>
>
> Hi All,
>
> I have two list Box items, list Box item1 and list Box item2,
> I display all
> the table names in the first list Box item1, then depending
> on the table
> name selected I have to select that particular select table
> columns from
> oracle data dictionary and display in the second list Box item2.
> Like that the user will select columns from few table, which
> I have to keep
> track, like to which table the column belongs.
>
> Any ideas, or suggestions of any form are welcome.
>
> I am using JSP and servlets technology.
>
> Bye
> Srikanth
>
>
> -----Original Message-----
> From: Scott Evans [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, October 29, 2000 8:22 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Passing Value from one frame to another
>
>
> With or without a trip to the server?
>
> -----Original Message-----
> From: Mukka, Srikanth [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 25, 2000 9:59 PM
> To: [EMAIL PROTECTED]
> Subject: Passing Value from one frame to another
>
>
> Hi All,
>
>
> I have two frames,frame1 and frame2, I am displaying one
> a.html in frame1
> and b.html in frame2. User selected value from the list box
> from a.html and
> depending on the value selected in a.html, I want to display
> the values in
> frame two using b.html. I question is how do I pass values in
> this scenerio.
> May be this is a small doubt.
>
> Bye
> Srikanth
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ==============================================================
> =============
> To unsubscribe: mailto [EMAIL PROTECTED] with body:
> "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets