I wrote some code that will grab the selected items and place them at the
top of the list, then list below that all unselected items -- it actually
works pretty well and is (of course) browser independent.

If anyone is curious on how this is done -- I've put some sample code below
as an example:

<?

    $states = array('ca'=>'California','nv'
=>'Navada','tx'=>'Texas','ri'=>'Rhode Island,'co'=>'Colorado');
    $mySelections = 'ca,tx,ri';

    $selectedItems = explode(',', $mySelections);

    /* This 1st FOREACH command builds the list showing only selected items
(at the top) */
    foreach($states as $key=$value)
    {
        if(in_array($key, $selectedItems))
        {
            print('<option value="' . $key . '"' . selected  .'>' . $value);
            print("\n");
        }
    }

    /* This 2nd FOREACH command builds the list, omitting any SELECTED items
*/
    foreach($states as $key=>$value)
    {
        /* If $key is in the array $selectedItems then CONTINUE the loop
here (skipping the print commands) */
        if(in_array($key, $selectedItems))
            continue;

        print('<option value="' . $key . '">' . $value);
        print("\n");
    }

Thanks.


"Jason Caldwell" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have a (multiple selection) select list on my web page -- My pages are
> setup with Save & Go Back buttons (through sessions) -- in IE when I
select
> multiple items (or any item) then go forward to the next page, then go
> back -- the items are still selected, but the select list starts at the
> top -- hence, I have to scroll down to see my selected items... just
FYI --
> I'm building the select lists (and what selected) programmatically -- when
I
> say I "Go Back" -- I'm not using the browsers back button -- but instead
the
> form button I created for this purpose.
>
> Now -- interestingly, in NS6 -- when I go back the select list starts at
the
> *last* selected items, hence I am thrown into my selected choices -- this
is
> desirable.
>
> Is there a way with PHP I can make IE kinda do the same thing?
>
> Thanks
> Jason
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to