set_select()

set_select($field[, $value = ''[, $default = FALSE]])

Parameters:
  • $field (string) – Field name
  • $value (string) – Value to check for
  • $default (string) – Whether the value is also a default one
Returns:

‘selected’ attribute or an empty string

Return type:

string

If you use a <select> menu, this function permits you to display the menu item that was selected.

The first parameter must contain the name of the select menu, the second parameter must contain the value of each item, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE).

Example:

<select name="myselect">
        <option value="one" <?php echo  set_select('myselect', 'one', TRUE); ?> >One</option>
        <option value="two" <?php echo  set_select('myselect', 'two'); ?> >Two</option>
        <option value="three" <?php echo  set_select('myselect', 'three'); ?> >Three</option>
</select>
doc_CodeIgniter
2016-10-15 16:32:39
Comments
Leave a Comment

Please login to continue.