[NOTE: Code included, so this post is long]

In regards to your 2nd question, I recently tackled that, myself. Those arrow buttons are done in JavaScript, though I guess you could do them with forms, too.

First, the HTML:

--------------------------
            <div class="listing_category_box">
                <div class="all_categories_box">
                    <div class="block_heading">Available Categories</div>
<select name="all_categories" class="listing_category" id="all_categories" size="8" width="422" MULTIPLE>
                    <!-- TMPL_LOOP NAME="categories" -->
<option value="<!-- TMPL_VAR NAME="id" ESCAPE=HTML -->"><!-- TMPL_VAR NAME="category" ESCAPE=HTML --></option>
                    <!-- /TMPL_LOOP -->
                    </select>
                </div>
                <div class="directional_buttons">
<button class="arrow_buttons" onClick="javascript:add_categories();return false;">&gt;&gt;</button> <button class="arrow_buttons" onClick="javascript:remove_categories();return false;">&lt;&lt;</button>
                </div>
                <div class="destination_categories_box">
<div class="block_heading">Your Listing Categories</div> <select name="listing_category" class="listing_category" id="listing_category" size="8" width="422" MULTIPLE>
                    </select>
                </div>
            </div>

--------------------------

Then I have these JavaScript functions to move the categories back & forth and I also use the Prototype library to make it easier:

--------------------------

<script src="/javascripts/prototype.js" type="text/javascript" lang="JavaScript"></script>
<script type="text/javascript" lang="JavaScript">

function add_categories() {
    var options = $('all_categories').options;
    var dest_control = $('listing_category');
    var dc_index = dest_control.options.length;
    var i;

    for ( i=0; i<options.length; i++ ) {
        if ( options[i].selected ) {
if ( _not_already_here( options[i].value, dest_control.options ) ) { dest_control.options[dc_index] = new Option( options[i].text, options[i].value, false, false );
                dc_index++;
            }
        }
    }
    // this is a support method that I use to dynamically update
    // other things via AJAX
    // form_changed( $('onesource_form'), '' );
    return false;
}

function _not_already_here( value, options ) {
    var not_already_here = true;
    var i;

    for ( i=0; i<options.length; i++ ) {
        if ( options[i].value == value ) {
            not_already_here = false;
            break;
        }
    }
    return not_already_here;
}

function remove_categories() {
    var dest_control = $('listing_category');
    var options = dest_control.options;
    var i;
    var len = options.length;
    var options_to_remove = new Array();

    for ( i=0; i<len; i++ ) {
        if( options[i].selected ) {
            options_to_remove.push( options[i] );
        }
    }

    len = options_to_remove.length;
    for ( i=0; i<len; i++ ) {
        dest_control.removeChild( options_to_remove[i] );
    }
    // this is a support method that I use to dynamically update
    // other things via AJAX
    // form_changed( $('onesource_form'), '' );
    return false;
}

</script>

--------------------------

Lastly, I needed to add a function that would select all of the options in the destination select box. When the user hits submit, some of those options may not be selected and thus, not passed through.

First, the form's submit button:

--------------------------

            <input type="submit" name="submit"
                                   value="save" class="submit"
                                   onClick="pre_submission();" />

--------------------------

Then the new function in the javascript code:

--------------------------

// When the user hits 'Submit', the listing_category may not
// have their selections selected, which won't get passed through.
// So we need to iterate through all selections and select all
function pre_submission() {
var listings = document.getElementsByClassName( 'suffix', $('listings') );
    for ( var i = 0; i < listings.length; i++ ) {
        var suffix = listings[i].value;
                var select_control = $('listing_category' + suffix);
                var categories = select_control.options;
                for ( var j = 0; j < categories.length; j++ ) {
                        categories[j].selected = true;
                }
        }
}

--------------------------

HTH!

- Jason

Michael Lackhoff wrote:
Hello,

I followed the advice from this list and wrote mod_perl authentification- and authorization handlers to move this task from my application to apache. But now I have the problem that for this kind of authentification there is no 'logout' functionallity. How do others handle this problem? The best I could come up with was a tweak to the authentification handler that gives back an 401 error to everyone for the location /myapp/logout and then write my own error document for this location saying "Logout successful" or something like that. But still the user gets the pop up box from the browser to reauthentificate. Any better ideas?

My second question is really off topic but perhaps someone can give me a short hint. I need a pair of multiple select boxes where one can move entries from one box to the other by clicking on an arrow button. There are some scripts out there that do what I want but I would prefer not to include many little script files to my application but rather do such stuff with the help of the big libraries like prototype and scriptaculous that I need anyway and that are well maintained. Does anyone know a solution based on one of these (or similar) libraries?

Thanks,
Michael


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to