Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

CornerBLUE, Inc. http://www.cornerblue.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

PHP: Create a SELECT input field

Creates a SELECT input field with an optional parameter to preselect an item

   1  
   2  function selectfield($optionsarray, $selected = "") {
   3    $returnval = "";
   4    foreach ($optionsarray as $field=>$value) {
   5      if ($field == $selected) {
   6        $returnval .= "<option selected value='" . $field . "'>" . $value . "</option>\n";
   7      } else {
   8        $returnval .= "<option value='" . $field . "'>" . $value . "</option>\n";
   9      }
  10    }
  11    
  12    return $returnval;
  13  }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS