douhuai4155 2015-10-23 17:22
浏览 60
已采纳

从PHP下拉列表中获取选定的值

I have a drop-down button in my page and it is defined in html. What I need is like when I go to next page I need to use this selected value there . I dont know how is it possible . I tried searching about it and I am not getting anything . I am new in this field . Can some please tell me how to make it possible. I am attaching my code part in here .

<!DOCTYPE html>
<html>
<head>
    <title>Demo</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="description" content="Home">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="bootstrap.css">


</head>

    <div class="container">
<select class="form-control" >
    <option value="ah">1</option>
    <option value="aa">2</option>
    <option value="aet">3</option>
    <option value="amt">4</option>

</select>
<br>
<?php 


        echo "<form action=log_file.php method=GET>";
        echo "<td>" ." <input type = text class = form-control name = admin_search placeholder = 'Enter  Name'>". "</td>";
        echo"<br>";
            echo "<td>" ."<input class=btn type=submit value=select". "></td>";


        echo "</form>";

        ?>
 </body>
  • 写回答

2条回答 默认 最新

  • downloadbooks_2014 2015-10-23 17:29
    关注

    You should put select block (with a name) in the form block.

    echo "<form action=log_file.php method=GET>";
    echo "<td>" ." <input type = text class = form-control name = admin_search placeholder = 'Enter  Name'>". "</td>";
    
    echo '<td><select class="form-control" name="select-val">
        <option value="ah">1</option>
        <option value="aa">2</option>
        <option value="aet">3</option>
        <option value="amt">4</option>
    </select></td>';
    echo "<br>";
    echo "<td>" ."<input class=btn type=submit value=select". "></td>";
    
    
    echo "</form>";
    

    And in the next page you can get selected value using

    echo $_GET["select-val"];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号