Login   Register  
PHP Classes
elePHPant
Icontem

File: detail_explanation

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Carlos Falo Hervás  >  linked_select  >  detail_explanation  >  Download  
File: detail_explanation
Role: Documentation
Content type: text/plain
Description: An example (though not a CODE EXAMPLE) showing what the class can do
Class: linked_select
Multiple dependent (linked) <select> tags
Author: By
Last change: setting roles
Date: 2002-07-26 09:49
Size: 1,346 bytes
 

Contents

Class file image Download
This class creates entries for a select (pull down) menu (a form <select> element) and generates all JavaScript and data required for a related select (secondary <select>) that has different options (<option elements with different value) for each primary <select> element...

let's see an example...

You have 2 related tables:

first table (table 1) layout is

	ID -> unsigned int primary key
	NAME-> varchar(50)

second table (table 2) layout is

	ID -> unsigned int primary key
	PARENTID -> unsigned int (TO JOIN WITH table 1)
	NAME -> varchar(50)

So data in the tables is as follows:

	table 1:

	1 | FRUITS
	2 | VEGETABLES
	3 | TREES

	table 2:

	1 | 1 | APPLE
	2 | 1 | PEAR
	3 | 2 | CUCUMBER
	4 | 3 | PALMTREE
	5 | 2 | LETTUCE
	6 | 1 | MELON
	7 | 3 | ACORN TREE

So with linked select you generate 2 selects, first one shows FRUITS/VEGETABLES/TREES (primary select, values are 1,2 & 3 respectively)

When you select an element in this select, secondary select show options depending on the option selected:

  if select 1 shows FRUITS then options in select 2 are APPLE/PEAR (with values 1,2)
  if select 1 shows VEGETABLES then options in select 2 are CUCUMBER/LETTUCE (with values 3,5)	
  if select 1 shows TREES then options in select 2 are PALMTREE/ACORN TREE (with values 4,7)

Got it? ;)