在PHP中选择默认选项下拉列表

时间:2016-10-06 11:38:38

标签: php html drop-down-menu dropdown html.dropdownlistfor

这是我的代码:

<?php
$PricerrTheme_enable_dropdown_values    = get_option('PricerrTheme_enable_dropdown_values');
                            $PricerrTheme_enable_free_input_box     = get_option('PricerrTheme_enable_free_input_box');
                            $x = (isset($_POST['job_cost']) ? $_POST['job_cost'] : $_SESSION['job_cost']);
echo PricerrTheme_get_variale_cost_dropdown('do_input', $x);
?>

问:这些选项是从db中选择的,它们是定价集,如$ 1,$ 2,$ 3,$ 4,$ 5等。如何默认选择$ 5选项而不是当前默认为最低的1美元选项?

1 个答案:

答案 0 :(得分:0)

使用selected="selected"。同样<option selected>这也是selected="selected"

的模拟器
    <option selected="selected">
       $5
    </option>
相关问题