Forum Moderators: phranque

Message Too Old, No Replies

Double combos!

What else could be used?

         

Alternative Future

10:54 am on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I am looking for ideas on replacing our current double combo select boxes in our application Non-JavaScript... Any ideas are appreciated :)

A little background:

  1. Currently we have a JavaScript double combo in place that populates the second select box with the items associated from the first selection.
  2. This has grown to an unmanageable size; therefore the JavaScript is quite extensive in size.
  3. I have looked around for a tag library that might have been able to assist with what we are trying to do, but no joyz, all still seem to be in development or on the to-do list! We are using JSP/Struts and running on IIS.
  4. We could make a custom tag library to do it, but would prefer to avoid this and get a ready-made script; this is down to time constraints. But we might have to accept the idea of making a custom one if this is the only line of attack we have.

Question:
  1. Is there any other way of completing this, where when the client selects an item we can display a list of associated items to that particular selection? I know we could have a pop-up populated with the associated items to the first selection, but I think we would rather like to keep away from using pop-ups in the application.
  2. Has anyone ever came across any HTML that can do what we are trying to do avoiding JavaScript where we could send a query to the database and have the second selection made available to the client without if possible refreshing the page?

I hope this makes sense, grammar and I don’t mix that well ;) Again many thanks for any ideas or inspirations that you guyz might have!

KR,

-gs

garann

4:18 pm on Jul 31, 2003 (gmt 0)

10+ Year Member



I may not be following, because I can't see why you would use a tag library, but could you use a "wizard" approach? That is, they choose the item in the first list-box on page 1, submit to page 2 and see the second list-box, populated according to the passed-in value of the first-list box?

A tag library would necessitate going back to the server and a database call every time the user clicked a button, right? If you have so much data it's slowing down your page, isn't that a database you'd want to query as little as possible?

g.

moltar

4:32 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I did it the following way:]

User selects the first drop down box and JavaScript executes onchange="document.FORMNAME.submit()". This submits the document.

In my script I read all the values and determine what to show in the second selection. Populate selection and display HTML to the browser. I actually have three choices.

I sent you a sticky with example.

Alternative Future

4:39 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi garann,

Many thanks for your response! In answer to your suggested fixes:
The reason the select boxes are on the one page is to filter the query that will be shown in the search. At present we have an upper template/tile with a few text boxes and the select boxes (in total around 9 of these are on the page) with the search button, below is where the results are shown. I think by adding another page to this equation would only complicate the process (but I shall put it forward).

>A tag library would necessitate going back to the server and a database call every time the user clicked a button, right?
This is correct, this is what we were trying to avoid hence the reason I included
>Has anyone ever came across any HTML that can do what we are trying to do avoiding JavaScript where we could send a query to the database and have the second selection made available to the client without if possible refreshing the page?

>If you have so much data it's slowing down your page, isn't that a database you'd want to query as little as possible?
What we are trying to do is avoid having so much html/javascript and programming logic on one page!

Thanks for that suggestion though J

-gs

Iguana

4:42 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I do it with remote scripting - but it does involve javascript. When a user clicks on the first combo the onclick event calls a javascript function that creates an iframe and sets the location of the iframe to a special form that queries the database. When the iframe page has loaded it calls back to the parent page (the callback function name was passed as a parameter) with the data and the callback function fills the 2nd combo with just the relevant entries.

I had to it this way because having thousands of codes in a javascript was making the page very slow to load.

I found some decent code on the Internet (it works for various versions of IE5+ and Netscape6+) to base my code on - just search for 'remote scripting iframe' and it will be the top result

killroy

4:43 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well you could make the second list into an iframe.

On the other hand you can also do a lot with invisible frames. You'd submit the first selection to an invisible frame, which then would fetch the datae from th eserver. But you would still need javasript to submit and do the populating.

SN

Alternative Future

7:41 am on Aug 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for all replies it gives me some food for thought!

moltar are you using Perl or CGI?

IFrames sounds like a nice way forward, does it have any effect on overheads etc? (speed & performance is the issue we are trying to avoid) I realize that avoiding a minimal amount of JavaScript is unavoidable!

KR,

-gs