PHP Classes
elePHPant
Icontem

linked_select: Multiple dependent (linked) <select> tags

Recommend this page to a friend!
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2004-05-19 (12 years ago) RSS 2.0 feedNot enough user ratingsTotal: 2,623 All time: 1,410 This week: 946Up
Version License Categories
linked_select 1.0.0GNU General Publi...HTML, Databases
Description Author

Class that generates 2 form select elements linked together, so changes on primary select rebuild the list of values for secondary select. It is crossbrowser for IE 5.x,NS4.x & NS5+ (Gecko/NS6)

Added adv. linked select, works in a similar way but allows for any number of chained selects!!! (this was a new release due to many mails asking for it). See the example to know how to use as I had no time to write the docs yet.

Picture of Carlos Falo Hervás
Name: Carlos Falo Hervás <contact>
Classes: 10 packages by
Country: Spain Spain
Innovation award
Innovation award
Nominee: 1x

Details
===== BASIC DOCUMENTATION FOR LINKED_SELECT CLASS =====

0.- INTRODUCTION AND EXTENTS

This tricky class was developed for a site requiring dynamic select content... I must tell
the general load for the page might be quite high depending on the data required from the
database operations.

It has been tested in all major 3 browsers (IE 5.x, NS4.x,NS5+) and generates the appropiate
code for each browser.

1.- BASICS OF OPERATION

Linked_select operation works creating a group of arrays with appropiate names and changing the
options collection (in DOM or DHTML model according to browser support)

This class requires classes:

	mysql_conn
	mysql_recordset

Both classes can be found in Database section under the name "mysql_db" in PHP Classes website
(see section 2)


PUBLIC INTERFACE:

  This class works in just 4 functions:

  linked_select($conn,$name,$tblname,$b0,$valuefld,$textfld,$selected=0,$subtblname,$s0,
		$subvalfld,$subtxtfld,$dependfld,$subselected=0,$debug=0)

    The constructor:

	$conn-> string for the name of a valid mysql_conn object
	$name-> basename for the linked_select items
	$tblname-> base table for primary select
	$b0->text displayed as 0 Element for primary select
	$valuefld-> field in $tblname for the value of the options in primary select
	$textfld-> field in $tblname for the text of the options in primary select
	$selected-> determines initial selected item in primary select
	$subtblname-> base table for secondary select
	$s0-> text displayed as 0 Element for secondary select
	$subvalfld-> field in $subtblname for the value on the options in secondary select
	$subtxtfld-> field in $subtblname for the text on the options in secondary select
	$dependfld-> dependent field in $subtblname that matches $valuefld in $tblname for linking
	$subselected-> determines initial selected item in secondary select NOT COHERENT, IF NOT FOUND NO SELECTION MADE (0 elem)
	$debug-> determines echo operations

  create_javascript()

    Generates the JavaScript interface for the select operations (creates it's own <script> tags)


  create_base_select()

    Creates primary select.  Must be called within a form

  create_sub_select()

    Creates secondary select. Must be called within a form

JAVASCRIPT PUBLIC INTERFACE:

  makeselect(frm,sel)

    frm-> form object (i.e. this.form or document.forms['frmname'])
    sel-> string with the name for the secondary select

    First eliminates all entries in secondary select and populates it based on primary select
    currently selected option

    Initially secondary select is populated form data according to primary select value
  
2.- Future releases and WIP

  This class is not finished, but is quite usable.  New releases will be posted at 
  http://phpclasses.upperdesign.com

  WIP on better browser detection, better select control operations, a 0-frame BASED version 
  and some extra crossbrowser details.

  Any suggestions are wellcome

3.- Contact information

  Carlos Falo Hervás
  carles@bisinteractive.net
  http://www.bisinteractive.net

  C/Manila 54-56 Esc. A Ent. 4ª
  08034 Barcelona Spain

  Phone: +34 9 3 2063652
  Fax:	 +34 9 3 2063689
  Files folder image Files  
File Role Description
Accessible without login Plain text file adv_example_result.htm Output The result of the example execution
Accessible without login Plain text file adv_linked_example.php Example A little example for the adv class
Plain text file adv_linked_select_class.php Class An improved version
Accessible without login Plain text file detail_explanation Doc. An example (though not a CODE EXAMPLE) showing what the class can do
Accessible without login Plain text file example.php3 Example an example
Plain text file linked_select_class.php Class linked select base class
Accessible without login Plain text file readme.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,623
This week:0
All time:1,410
This week:946Up