<?
function CityListSafFunctionV2($myname,$myarrayvalue=1,$myprinttext="N",$printallalso="",$myindex="",$style="textbox",$javascript="",$myid="",$SelectOne=""){
$myarray[1] = "Colombo";
$myarray[2] = "Negombo";
$myarray[3] = "Dickwella";
$mynumberfoarrays = 3;
if ($myid) {
$myid='id=\"'.$myid.'\"';
}
if ($SelectOne) {
$SelectOneVal="<option value=\"\" selected>$SelectOne</option>";
}
if ($myname == "null" $myname == "NULL"){return $myarray[$myarrayvalue];}else{if ($myindex) {$myindex = "tabindex=\"$myindex\"";}$mytext .= "<select $myid name=\"$myname\" class=\"$style\" $myindex $javascript>";for ($i=1; $i<=$mynumberfoarrays; $i++){if ($i == $myarrayvalue){$select = " selected ";}if ($myarray[$i] == $myarrayvalue){$select = " selected ";}$mytext .="<option value=\"";if ($myprinttext=="Y") {$mytext .="$myarray[$i]";}else{$mytext .="$i";}$mytext .="\" $select >$myarray[$i]</option>";$select = "";}if ($printallalso) {$mytext .= '<option value="all">'.$printallalso.'</option>';}$mytext .="$SelectOneVal</select>";
return $mytext;
}
}
?>
This function is very smart and without this function I don't even think a project,
This function can use as a small storage, you can store some records and call back or you can use this a drop down (combo) in any place using PHP
You can pass Tab Index, Java Script, ID, Field Name and more, I posting this for my reference and for my students, If you can mane please feel free to use, and also If you have any problems please post as comment.