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: 7 years ago
Size: 515 bytes


Class file image Download


$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>


<title>Select Option Example</title>

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

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