Results 1 to 3 of 3

Thread: Combo Box viewer: remembering after reloading

  1. #1
    Join Date
    Jul 2005
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Combo Box viewer: remembering after reloading

    Script: Combo Box viewer

    http://www.dynamicdrive.com/dynamici...omboviewer.htm

    Problem: I'd like to have the combo box list contain links that call the same page that the combo box itself is on, but doing so resets the combo box to the first selection on the list, even in the absence of instructions to do so. Is there any way to have the same selected choice and corresponding subset of links persist?

    In case this isn't clear, here's my working document:

    http://www.bio.georgiasouthern.edu/G...rlistmod1.html

    The combo box in question is in the left column. Clicking on the link is supposed to insert stuff relevant to the chosen species in the proper location in the right column. The problem to which I refer can be seen if you select a list other than Annelida (say, Vertebrates), and then click on a species name from the new list. You get the proper information on the right, but the combo box on the left resets itself to Annelida. I'd rather the combo box in this example continue to show the Vertebrates list rather than revert to the Annelid list!

    (By the way, I know there are other things that don't work on this page yet. I'm plowing through the issues one at a time. You should have seen this thing this morning!)

    Thanks in advance for any suggestions.

    Alan

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by aharvey
    resets the combo box to the first selection on the list, even in the absence of instructions to do so
    Well, reloading the page is 'instructions to do so'. When you click on one of those links you are reloading the page with new information in the address as to what to display on the right. So anyways, to avoid this we must give additional instructions on page load. I see you are already passing information to the page about what to display on the right. If you test the url you could determine which drop contents to display based upon that:
    Code:
    <script type="text/javascript">
    var chkURL=unescape(location.href)
    if (chkURL.indexOf('Actinopygaagassizii')!==-1)
    document.dropmsgform.dropmsgoption.selectedIndex=5
    </script>
    This script should go directly after the the form. Remember that options are numbered starting at 0 so 5 corresponds to:
    HTML Code:
    <option>Echinodermata (sea stars, sea cucumbers, sea urchins, etc.)</option>
    You will of course need to expand considerably upon the above script adding in tests for each ?spp= keyword that you have and associating it with the correct option number from the form. Just follow the the pattern of:
    Code:
    if (chkURL.indexOf('wordToCheckFor')!==-1)
    document.dropmsgform.dropmsgoption.selectedIndex=actualNumberOfOption
    adding each beneath the one I've supplied:
    Code:
    <script type="text/javascript">
    var chkURL=unescape(location.href)
    if (chkURL.indexOf('Actinopygaagassizii')!==-1)
    document.dropmsgform.dropmsgoption.selectedIndex=5
    if (chkURL.indexOf('wordToCheckFor')!==-1)
    document.dropmsgform.dropmsgoption.selectedIndex=actualNumberOfOption
    </script>
    Order is unimportant but, you will want to go in sequence to make sure you haven't missed any.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2005
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    John,

    Thanks for your insights. That specific approach would have been impractical since there are already over 300 species on the list and counting, but I was able to modify your suggestion to get the desired result by adding info to the URL and including a stripped-down version of the script you provided. Works like a charm.

    Can't tell you how much this site has helped me!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •