简体   繁体   中英

Select a default option dropdown list in PHP

This is the code I have:

<?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);
?>

Q: The options are selected from db, which are pricing sets like $1,$2,$3,$4,$5 etc. How do I select by default the $5 option instead of it currently defaulting to the lowest $1 option?

use selected="selected" . also <option selected> this is also similer to the selected="selected"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM