PHP Classes
elePHPant
Icontem

Editable select input : Generate form select input with editable text

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2006-03-25 (9 years ago) RSS 2.0 feedNot enough user ratingsTotal: 1,479 All time: 2,499 This week: 1,146Up
Version License PHP version Categories  
editableselect 1.0GNU General Publi...3HTML
Description Author  

This class can be used to generate a form select input with a text input that can alter the selected value.

This class is a PHP wrapper of a JavaScript example made available in the dhtmlgoodies.com site.

The class outputs the necessary JavaScript and HTML to generate a text input with menu that opens when the user clicks on the pull-down menu button.

The user can choose one of the listed entries of the menu to set the text input value. The list of the menu entry values is defined by a string with multiple values separated with a semi-colon.

Picture of Andrea Bersi
Name: Andrea Bersi <contact>
Classes: 3 packages by
Country: Italy Italy
Age: 49
All time rank: 2638 in Italy Italy
Week rank: 1541 Down68 in Italy Italy Down

Details provided by the author  
If you want to use the values stored into a table of a mysql db, it is very simple. Add, for example, a wrapper (in this example the ez_sql.class You find it in the site phpclasses.org)

include ("include/ez_sql.php");

After, you query your db as


if ( $mails = $db->get_results("SELECT mail FROM mail") )
{
	// Loop through the resulting array on the index $users[n]
	foreach ( $mails as $mail )
	{
		// Access data using column names as associative array keys
		$str.=$mail->mail.";";
        }
}
$select->print_select("mail",$str);
?>  

The select is at this point with the values of db

At the post of form you insert the value in the db if it is not present

if(isset($_POST['mail'])) {
//verifica se la mail inserita era giÓ nel db o no
if (!( $n = $db->get_var("SELECT count(*) FROM mail WHERE mail = '$_POST[mail]'") ))
{
	// Insert into the database
	$db->query("INSERT INTO mail (mail) VALUES ('$_POST[mail]')");
}  
.... other instructions
}
  Files folder image Files  
File Role Description
Files folder imageimages (3 files)
Plain text file editselect.php Class Tha class
Accessible without login Plain text file index.php Example Example
Accessible without login Plain text file readme_db.txt Doc. tip for use with a db
Accessible without login Plain text file vai.php Example Test page

  Files folder image Files  /  images  
File Role Description
  Accessible without login Image file select_arrow.gif Data images
  Accessible without login Image file select_arrow_down.gif Data image
  Accessible without login Image file select_arrow_over.gif Data image

 Version Control Unique User Downloads Download Rankings  
 0%Total:1,479All time:2,499
 This week:0This week:1,146Up