【问题标题】:Select a default option dropdown list in PHP在 PHP 中选择默认选项下拉列表
【发布时间】:2016-10-06 11:38:38
【问题描述】:

这是我的代码:

<?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 美元选项?

【问题讨论】:

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


    【解决方案1】:

    使用selected="selected"。还有&lt;option selected&gt; 这也类似于selected="selected"

        <option selected="selected">
           $5
        </option>
    

    【讨论】:

    • 我在 end ?> 命令之后添加了它。问题是,它没有在下拉列表中选择任何内容,它只是在下拉框本身下方显示文本“$5”。
    • &lt;?php $PricerrTheme_enable_dropdown_values = get_option('PricerrTheme_enable_dropdown_values'); $x = (isset($_POST['job_cost']) ? $_POST['job_cost'] : $_SESSION['job_cost']); echo PricerrTheme_get_variale_cost_dropdown('do_input', $x); ?&gt; &lt;option selected="selected"&gt; $5 &lt;/option&gt;
    • select 标签在哪里??不是选择
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-29
    相关资源
    最近更新 更多