Return to Snippet

Revision: 14631
at June 8, 2009 09:19 by erichelgesen


Initial Code
function generate_select($values,$selected,$usekey=''){
	foreach ($values as $key=>$data){
		if(!empty($usekey)){$option_value = $key;}
		else{$option_value = $data;}
		if($selected == $option_value){echo "<option value = '$option_value' selected>$data</option>";}
	else{
		echo "<option value = '$option_value'>$data</option>";
		}
	
}

Initial URL

                                

Initial Description
Use this to generate a select box

Initial Title
Generate Select Box

Initial Tags
form

Initial Language
PHP