无法从select元素中获取值。 (PHP / HTML)

时间:2016-04-19 04:12:22

标签: php html

我试图获取下拉菜单的值。用户点击按钮selectOptionud后会创建下拉菜单。但是,当我回复<html> <body> <?php if (isset($_POST['submitundrafted'])) { $selectOptionud = $_POST['filter_ud']; //undrafted selection echo $selectOptionud; }//end of submitundrafted if (isset($_POST['undrafted'])) { $menu= "<select name='filter_ud' id='filter_ud'> " . $options . " //I have erased the previous code that gets the value of this variable. </select>"; echo $menu; ?> <form action="transfer.php" method="post"> <input type="submit" name="submitundrafted" value="Submit" /> </form> <?php } ?> <form action="transfer.php" method="post"> <input type="submit" name="undrafted" value="With Undrafted Players"> </form> </body> </html> 时,我没有任何价值。知道这里发生了什么吗?

no implicit conversion of String into Integer

1 个答案:

答案 0 :(得分:0)

此处$options将是这样的

<option value="1">abc</option>
<option value="2">bcd</option>
<option value="3">def</option>

     if (isset($_POST['undrafted'])) {   
        $menu= "<select name='filter_ud' id='filter_ud'>
                                    " . $options . " //I have erased the previous code that gets the value of this variable.
                 </select>";
     ?>
     <form action="transfer.php" method="post">
        <?php echo $menu;?>
        <input type="submit" name="submitundrafted" value="Submit" />
     </form>
     <?php
      }?>