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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?