Results 1 to 5 of 5

Thread: Scrolling a Select

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032

    Scrolling a Select

    Anyone know a quick official way to scroll a multiple-selection SELECT to the seleted item at page load (option is dynamically picked by server-side script, out of potentially hundreds of choices)? I don't see anything in the W3 DOM, but I could be overlooking it.

    I don't need to support anything less than 6.0 browsers, BTW, but I do need to be compliant with the W3 (because its stupid not too when you don't need to support older browsers). It's not that big a deal if there isn't - it's for a small bit of user friendlyness, not anything critical.

    Thanks.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    If you just want a way to select a particular option in a select box then I think you can do it for example like this:

    SelectId.selectedIndex=5

    Sorry if that's not what you want.

  3. #3

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    No, the script writes the "selected" to the desired option tag as the options are being pulled from the database. What happens is the the list has the first 15 items or so visible, but if the 30th item was selected, its not apparent to the user until they scroll down the list. I'd like it to autmatically scroll to the selected item at page load, if there's an item selected.

    Thanks anyway.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  4. #4
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    I very often find myself dissapointed with the select combo box, and I play with different way to mimic one with divs. The user doesn't even need to know that it isn't a real form element, except in this case, where I don't know how to mimic the scroll bar and manipulate it.

    If you are fine with the idea of using little arrow images to trigger scrolling and not have a bar, then you could set up a div to act like your form element.

    You make a div and style it to look like a combo box. You fill it with spans, each one being a single selectable item.

    An onClick event for the spans can swap the colors to highlight it.

    A down arrow image can have an onClick even to "scroll" the items in the div. It will remove the top span and add a new one to the bottom. Might work better with onMouseDown onMouseUp so they can hold it down.

    Anyway, I'm just tossing out ideas. I haven't played with some of these, but I would think they would all be possible.

    (wow, my grammar is just horrible today)
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  5. #5

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Hmm - I kinda wrote the code as a function that's reused on multiple pages, so I'm kinda stuck with <option> tags. It's not that critical to need to rewrite anything at this point. Thanks anyway.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

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



Click Here to Expand Forum to Full Width