PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Poomnatee   Select Option   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example code for how to use SelectOption Class
Class: Select Option
Generate HTML form select input option list
Author: By
Last change:
Date: 14 years ago
Size: 515 bytes
 

Contents

Class file image Download
<?php

include('SelectOption.class.php');

$data_array = array('1'=>'one' , '2'=>'two' , '3'=>'three' , '4'=>'four');

$obj = new SelectOption($data_array); //data array is key=>value format
$obj->setSelectedIndex('2'); //--- set <option value="2" selected="selected">two</option>

?>

<html>
<head>
<title>Select Option Example</title>
</head>
<body>

<select name="select1">
<option value="">--- please select ---</option>

<?php echo $obj->printOption(); ?>

</select>

</body>

</html>