PHP Classes

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    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 2,627 All time: 1,455 This week: 248Up
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
Age: 47
All time rank: 361 in Spain Spain
Week rank: 467 Down25 in Spain Spain Down
Innovation award
Innovation award
Nominee: 1x



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.


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:


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


  This class works in just 4 functions:


    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


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


    Creates primary select.  Must be called within a form


    Creates secondary select. Must be called within a form



    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

  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

  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  
This week:0
All time:1,455
This week:248Up
For more information send a message to info at phpclasses dot org.