简体   繁体   English

选择该选项后,不会收到下拉菜单中的值

[英]Value from dropdown menu is not received when the option has been chosen

The program starts with: 该程序开始于:

session_start();
$seq = 0;
if (isset($_POST['fname'])) {   
    echo $_POST['fname']."<br/>";
    if (isset($_POST['uid']) {
        echo $_POST['uid']."<br/>";
        if ($_POST['submit'] && $_POST['edupdel'] != "ABCD") {
            echo "postsubmit  = ".$_POST['submit']."<br/>";
            echo "edupdel = ".$_POST['edupdel']."<br/>";
            echo "past submit<br/>";

            $opt = $_REQUEST['edupdel'];
            echo "OPTION IS  = ".$opt;
        }   
    }   
}   
$fname  = $_POST['fname'];
$uid = $_POST['uid'];
$opt = $_POST['edupdel'];

echo $uid.$fname.$opt."<br/>";
echo "*******<br/>";
$seq = $seq + 1 ;
echo "SEQ # is = ".$seq."<br/>";

The idea being: uid and fname are being carried over since the first page and work OK. 自从第一页开始就一直保留uid和fname的想法,并且工作正常。 I can get those values correctly. 我可以正确获得这些值。 The program uses: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 该程序使用: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

(GET or REQUEST were options considered but so far no success). (考虑使用GET或REQUEST选项,但到目前为止没有成功)。 The program has a drop down menu. 该程序具有一个下拉菜单。 The first entry "ABCD" id just dummy for now and should not be used in the future. 现在,第一个条目“ ABCD”的标识只是虚拟的,将来不应使用。

Please select one of the options:
<select name="edupdel">
    <option value="ABCD">ABCD</option>
    <option value="edit">EDIT</option>
    <option value="update">UPDATE</option>
    <option value="delete">DELETE</option>
</select>

The submit goes like this: 提交过程如下:

<input type="submit" name="submit"  value="Submit" style="background-color:#FFFFFF" >
<input type="hidden" name="fname" value="<?php echo $_POST['fname']; ?>"> 
<input type="hidden" name="uid" value="<?php echo $_POST['uid']; ?>">
<input type="hidden" name="edupdel" value="<?php echo $_POST['edupdel']; ?>"> 

Now, from the top of my ignorance, I don't know how to retrieve the value for the: <select name="edupdel"> 现在,从我的无知开始,我不知道如何检索以下内容的值: <select name="edupdel">

This is not shown when I select, for example, the option EDIT from the menu. 当我从菜单中选择“编辑”选项时,则不会显示。 I'm not even sure that this is the correct way to obtain the value selected from the drop down list. 我什至不确定这是否是从下拉列表中选择值的正确方法。

So what do I expect: Have uid, fname and the selected option set so I can decide the next step. 所以我期望什么:设置uid,fname和selected选项,以便我决定下一步。 Please bear in mind that I'm starting with PHP and the whole shebang, so at this point, after looking in the forum for hours, I decided to take a shot and ask the forum guys what would be the best way to code what I need or just plain point me to some other possible options. 请记住,我是从PHP和整个Shebang开始的,所以在这一点上,在论坛上看了几个小时之后,我决定去看看,问问论坛上的人,什么是编码我的代码的最佳方法?需要或只是简单地指出其他一些可能的选择。

Some debugging data I could get to so far according to the "echos"  above:
mary
john 
postsubmit = Submit
edupdel =
past submit
OPTION IS = johnmary ( I would expect EDIT or UPDATE or DELETE after the word mary)
*******
SEQ # is = 1

It looks like you have a hidden input field after the submit button with the name edupdel . 看来您在名称为edupdel按钮之后有一个隐藏的输入字段。 If this is the case, anything in that input's value will override anything selected in the <select> field. 在这种情况下,该输入值中的任何内容将覆盖在<select>字段中<select>任何内容。

Try either removing that hidden field, or moving it above the <select> field in the HTML so the select takes precedence. 尝试删除该隐藏字段,或将其移到HTML中的<select>字段上方,以使选择优先。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 下拉菜单,选择后将选项变成按钮 - DropDown menu that when chosen turns option into a button 有没有办法检索已在下拉选择选项上设置的值? - Is there a way to retrieve a value that has already been set on a dropdown select option? 检查以确保已从中选择了一个选项 <select></select> 名单 - check to make sure a option has been chosen from <select></select> list 从下拉菜单中使用php获取选定的选项(下拉菜单也通过使用php创建) - get selected option from dropdown using php (the dropdown has been created by using php also) 选择下拉菜单中的选项时运行脚本 - Run script when an option from a dropdown menu is selected 在表单中选择类别时从子类别中的数据库中进行选择 - Selecting from a database in a sub category when a category has been chosen in a form 未选择图像文件时无法停止处理表格 - Not able to stop processing form when image file has not been chosen 从数据库中选择菜单后,PHP MySQL会从下拉菜单中保留选择的选项 - PHP MySQL keep selected option from dropdown menu when menu is select from database 当从另一个 select 中选择了特定选项时,隐藏多个 select 中的选项 - Hide an option in a multiple select, when a specific option has been selected from another select 仅当从下拉菜单中选择值时才显示结果 - display result from dropdown menu only when value from it is selected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM