douluo3256 2019-05-17 01:28
浏览 33
已采纳

表单提交Bootstrap下拉数据

I have the following code, I am trying to make it so that the selected field displays on a php page when I return that hit the submit button, I'm doing this below.

<form action="welcome.php" method="post">
<div class="form-group">
<select class="form-control" id="inputState" style="width: 100%">
    <option selected>
        Choose...
    </option>
    <option name="account" value="1">
        Minecraft Account
    </option>
    <option name="cape" value="2">
        Minecraft Cape
    </option>
</select>
</div>
<input type="submit">
</form>

this is my php echo code, but it does not work

<?php echo $_POST["account"]; ?>
<?php echo $_POST["cape"]; ?>
  • 写回答

1条回答 默认 最新

  • doubi7739 2019-05-17 01:32
    关注

    Set name to your select control

    <select name="inputState" class="form-control" 
    

    Then you can get the "value" of selected item

    <?php echo $_POST["inputState"]; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突