php - Set the default value of drop-down list with the last value chosen -
i'm using cakephp 1.2, , have search form has menu:
classificazione <select style="margin-top: 5px;" name="classificazione"> <option value="art0"></option> <option value="c">articoli</option> <option value="d">documentazione</option> <option value="a">libri</option> <option value="g">materiali</option> <option value="b">riviste</option> <default value="a"> </select><br />
in next page want set default value of menu user has chosen before.
i solved (for example, first option): in controller:
$getparams['classificazione'] = isset($params['classificazione']) ? $params['classificazione'] : ''; ... $this->set('getparams', $getparams);
in view:
<option value="c" <?php if ($getparams['classificazione']=="c") echo "selected"; ?> >articoli</option>
save value in session variable , utilize echo selected
option
<?php function is_selected($selected_option, $list_option_value) { if($selected_option == $list_option_value) { homecoming 'selected'; } } ?> <select> <option <?php echo is_selected($_session['selected_option'], '1'); ?>>1</option> </select>
php option cakephp-1.2
No comments:
Post a Comment