简体   繁体   中英

drop down value not post

Thanks to some help here, I have a drop down in an html form.

<p>
    <select id="CategorySelection">
        <option value="0">Choose One</option>
        <option value="Research">Research</option>
        <option value="Innovation">Innovation</option>
        <option value="Application">Application</option>
        <option value="Integration">Integration</option>
    </select>
</p>

Depending on what you choose - javascript shows different questions to follow this. The following questions and everything else are posting to the db (mysql) table fine. I can't get this value to post- it just shows NULL. Is there something I am missing because of the javascript? I am really new in that area. Thanks!

$_POST values derive from the name attribute, not the id. Your select just needs a name, like this:

 <select name="CategorySelection" id="CategorySelection">

Then you can access its value in the $_POST array as usual:

if (isset($_POST['CategorySelection'])){
    $category = $_POST['CategorySelection'];
}

您将select属性“id”设置为一个值,您需要为其设置“name”属性,然后从PHP的$ _POST数组中调用该键。

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