Basic Enterprise Application Realm

Basic Enterprise Application Realm Documentation

  • 1 PHP Reference
    • 1.1 Introduction
    • 1.2 shared_lib.php
    • 1.3 ac_tables.php
    • 1.4 ac_email.php
  • 2 Javascript Reference
    • 2.1 Introduction
    • 2.2 ac_ajax
    • 2.3 ac_event
    • 2.4 ac_filter
    • 2.5 ac_menu
    • 2.6 ac_panel
    • 2.7 ac_select
    • 2.8 ac_toc
  • 3 Forms
    • 3.1 Introduction
    • 3.2 How It Works
    • 3.3 AJAX
    • 3.4 form_processor_v2
    • 3.5 form_processor

2.7 ac_select

March 25th, 2025

This is a simple class that allows you to register a deck of HTML items to support intelligent selection highlighting. This basically means turning on row highlights when a checkbox is selected or designating a checkbox that allows one-click selection/deselection of all elements. This works for lists of items displayed as a true list (table rows) or a matrix of tiles (HTML tables laid out inside another table as a grid). The latter is becoming more common on mobile devices. Often, the list of items is unknown (dynamic). Therefore, the Javascript to call this will often be generated by your PHP to create the correct array of items in the "deck".

Current version: 2
Dependencies: ac_event_v2.js

2.7.1 Public Properties

None

2.7.2 Public Methods

Version Arguments Purpose
createDeck 2 group name (string), type (enumeration), items (array), all (string) Creates a deck of selectable items. This is generally cosmetic since the items must be selectable by HTML checkboxes anyway. The group argument is an arbitrary name for referring to (and possibly later overriding) the defined deck. The type argument controls the way highlighting works. The valid options are: tr = causes highlighting to occur on the first parent HTML <tr> element (rows). element = causes the highlighting to occur on a specific element ID (often a whole table). [null] = simply causes the highlight to apply to the parent HTML element (probably a <td>). The items argument must be an array of HTML IDs corresponding to HTML <input> elements of type checkbox. Finally, the "all" argument points to the ID and a HTML <input> element of type checkbox which is to be used for toggling all items on or off.

2.7.3 HTML Attributes

Version Type Mandatory [Y/N] Purpose
ac:select 2 string N When the type argument is element, this attribute is mandatory in each <input> checkbox tag in the deck. It should contain the unique ID of a HTML element to apply the highlighting to.

2.7.4 Usage example

Create a selectable deck of table rows

Javascript

var $a=['row_0','row_1','row_2','row_3','row_4','row_5']; ac_select.createDeck('deck1','tr',$a,'toggle');

HTML

<style>

.row_item_select { background-color: #333333; }

</style> <p>Select/Deselect all: <input name="toggle" type="checkbox" id="toggle" value="1"></p> <table cellspacing="0" cellpadding="3" border="0"> <tr class="row_item"> <td><input type="checkbox" name="row_0" id="row_0" value="0"></td> <td>Item 0</td> </tr> <tr class="row_item"> <td><input type="checkbox" name="row_1" id="row_1" value="1"></td> <td>Item 1</td> </tr> <tr class="row_item"> <td><input type="checkbox" name="row_2" id="row_2" value="2"></td> <td>Item 2</td> </tr> <tr class="row_item"> <td><input type="checkbox" name="row_3" id="row_3" value="3"></td> <td>Item 3</td> </tr> <tr class="row_item"> <td><input type="checkbox" name="row_4" id="row_4" value="4"></td> <td>Item 0</td> </tr> <tr class="row_item"> <td><input type="checkbox" name="row_5" id="row_5" value="5"></td> <td>Item 0</td> </tr> </table>

Note, the highlighting works by applying a style with the same name as the existing base style with the "_select" suffix.

previous: ac_panel next: ac_toc