Php 我想在ajax中选择相应下拉列表时发送相应文本字段的id

Php 我想在ajax中选择相应下拉列表时发送相应文本字段的id,php,jquery,ajax,Php,Jquery,Ajax,我想通过ajax发送id,同时选择相应的下拉列表。我的密码在这里。在这里,我有所有行的下拉列表,当我选择任何特定行的下拉列表id时,该行的id将消失,但在这里,每次只有第一行的id消失 <?php include('adodb/adodb.inc.php'); include('inc/config.php'); if(!isset($_SESSION['adminuserid'])) { header("location:login.php");

我想通过ajax发送id,同时选择相应的下拉列表。我的密码在这里。在这里,我有所有行的下拉列表,当我选择任何特定行的下拉列表id时,该行的id将消失,但在这里,每次只有第一行的id消失

<?php
    include('adodb/adodb.inc.php');
    include('inc/config.php');

    if(!isset($_SESSION['adminuserid']))
    {
    header("location:login.php");
    }


    $table="register";  





       $temp = $db->Execute("SELECT * FROM $table  ORDER BY id DESC " );

        $r['fname'] = $_REQUEST['fname'];
        $r['email'] = $_REQUEST['email'];
        $r['phone'] = $_REQUEST['phone'];
        $r['picuptime'] = $_REQUEST['picuptime']. "," . $_REQUEST['mm'];
        $r['picupdate'] = $_REQUEST['picupdate'];   
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Regular Booking| Othminicabs.co.uk</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<!--[if IE 9]>
    <link rel="stylesheet" media="screen" href="css/ie9.css"/>
<![endif]-->

<!--[if IE 8]>
    <link rel="stylesheet" media="screen" href="css/ie8.css"/>
<![endif]-->

<!--[if IE 7]>
    <link rel="stylesheet" media="screen" href="css/ie7.css"/>
<![endif]-->
<script type="text/javascript" src="js/plugins/jquery-1.7.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/custom/general.js"></script>
<script type="text/javascript" src="js/custom/tables.js"></script>



<!--[if lt IE 9]>
    <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->


<script type="text/javascript">
jQuery(document).ready(function() {
refreshCarLocation();
myFunction();
});

function refreshCarLocation(){


              jQuery.ajax({   
               url:"refresh.php",
               success:function(response){

                    jQuery('#driver').html(response);

                }           
          });
   } 


function myFunction()
{
setInterval(function(){
                        refreshCarLocation()
                      }
                        ,5000);
}
</script>

<script type="text/javascript">

function action()
{
    jQuery.ajax({

      url: "ajax/tabledata.php?id="+jQuery('#userid').val(),



    })

}


</script>






</head>

<body class="loggedin">

    <?php include("inc/header.php"); ?>
    <!-- START OF MAIN CONTENT -->
    <div class="mainwrapper">
        <div class="mainwrapperinner">

        <?php include("inc/mainleft.php"); ?>

      <div class="maincontent noright">
        <div class="maincontentinner">

            <ul class="maintabmenu">
                    <li class="current"><a href="index.php">Regular Booking</a></li>
                    <li><a href="dashboardcorporate.php">Corporate Booking</a></li>
                    <li><a href="dashboardpersonal.php">Personal Booking</a></li>
                    <li><a href="dashboardtopup.php">Topup Booking</a></li>
          </ul><!--maintabmenu-->



                 <div class="content2">
                                <div class="contenttitle radiusbottom0">
                    <h2 class="table"><span>RegularBooking Table</span></h2>
                </div><!--contenttitle-->


              <?php if($_GET['msg']=="update") { ?>
             <div class="notification msgsuccess" id="update" style="display:block;">
                        <a class="close"></a>
                       <p>Your Changes were <strong>Successfully</strong> Done! </p>
                        </div>
                   <?php } ?>     


                   <?php if($_GET['msg']=="mail") { ?>
             <div class="notification msgsuccess" id="update" style="display:block;">
                        <a class="close"></a>
                       <p>Your Job is <strong>Successfully</strong> Dispatched! </p>
                        </div>
                   <?php } ?>   

                    <?php if($_GET['msg']=="sorry") { ?>
             <div class="notification msgerror">
                        <a class="close"></a>
                        <p style="background:#FAD5CF">Sorry Your job is not Dispatched Please select active Driver!</p>
                    </div>
                   <?php } ?>





                   <table cellspacing="0" cellpadding="5" class="stdtable">

                   <tr>
                   <td>
                   <img src="images/bluedot.png" class="imgg"  />&nbsp;<strong>New</strong>
                   </td> 
                   <td>
                   <img src="images/reddot.png" class="imgg" />&nbsp;<strong>Cancelled</strong>
                   </td>
                   <td>
                   <img src="images/yellowdot.png" class="imgg" />&nbsp;<strong>Confirmed</strong>
                   </td>
                   <td>
                   <img src="images/browndot.jpg" class="imgg" />&nbsp;<strong>Pending</strong>
                   </td>
                   <td>
                   <img src="images/blackdot.png" class="imgg" />&nbsp;<strong>Posponed</strong>
                   </td>
                   <td>
                   <img src="images/greendot.png"  class="imgg"/>&nbsp;<strong>Confirmed Operator</strong>
                   </td>
                    <td>
                   <img src="images/greendot.png"  class="imgg"/>&nbsp;<strong>Confirmed Driver</strong>
                   </td>

                   </tr>
                   </table>






                <table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="dyntable">
                    <colgroup>
                        <col class="con0" />
                        <col class="con1" />
                        <col class="con0" />
                        <col class="con1" />
                        <col class="con0" />
                        <col class="con1" />
                         <col class="con0" />
                         <col class="con1" />
                          <col class="con0" />

                    </colgroup>
                    <thead>
                        <tr>
                            <th class="head0">#</th>
                            <th class="head1">Booking From</th>
                            <th class="head0">Pickup Postcode</th>
                            <th class="head1">Phone</th>
                            <th class="head0">Pickup Time</th>
                            <th class="head1">Pickup Date</th>
                             <th class="head0">Status</th>
                            <th class="head1">&nbsp;</th>
                            <th class="head0">&nbsp;</th>
                            <th class="head1">&nbsp;</th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                            <th class="head0">#</th> 
                            <th class="head1">Booking From</th>
                            <th class="head0">Pickup Postcode</th>
                            <th class="head1">Phone</th>
                            <th class="head0">Pickup Time</th>
                            <th class="head1">Pickup Date</th>
                             <th class="head0">Status</th>
                            <th class="head1">&nbsp;</th>
                             <th class="head0">&nbsp;</th>
                              <th class="head1">&nbsp;</th>
                        </tr>
                    </tfoot>
                    <tbody>
                       <? if(count($temp)==0) { ?>
                       <tr>
                                    <td colspan="14" align="center"><span style="color: red; font-weight: bold;">No records found.</span></td>
                                  </tr>
                         <? } else { ?>
                          <? foreach($temp as $k=>$r) { ?>
                        <tr class="gradeX">
                             <td class="center"><?=$r['id']?> </td>

                             <td class="center"><?=$r['booking_from']?></td>
                            <td class="center"><?= $r['picuppostcode'] ?></td>
                            <td class="center"><?=$r['phone']?></td>
                            <td class="center"><? $time = explode(',',$r['picuptime']); ?>
                                    <?= $time[0] ?>hrs <?= $time[1] ?> mnts</td>
                            <td class="center"><?=$r['picupdate']?></td>

                         <?php if($r['status']=="New"){?>
                            <td class="center"  title="New" >
                          <img src="images/bluedot.png" alt="new" /></td>

                            <?php  } elseif($r['status']=="Cancelled") { ?>

                             <td class="center" title="Cancelled">
                          <img src="images/reddot.png"  /></td>

                           <?php  } elseif($r['status']=="Confirmed") { ?>

                             <td class="center" title="Confirmed">
                          <img src="images/yellowdot.png"  /></td>


                           <?php  } elseif($r['status']=="Confirmed Operator") { ?>

                            <td class="center" title="Confirmed Operator">
                          <img src="images/greendot.png"  /></td>

                             <?php  } elseif($r['status']=="") { ?>

                              <td class="center">No status</td>

                              <?php  } elseif($r['status']=="Posponend") { ?>
                               <td class="center" title="Posponend" >
                               <img src="images/blackdot.png" />
                               </td>


                               <?php  } elseif($r['status']=="Pending") { ?>
                               <td class="center" title="Pending">
                               <img src="images/browndot.jpg" />
                               </td>

                          <?php } ?>

                        <td class="center"><a href="ajax/tabledata.php?id=<?=$r['id']?>" class="toggle">Quick View</a></td>
                        <td class="center"><a href="Map.php?id=<?=$r['id']?>" class="toggle">Show Map</a></td> 
                       <td> 
                       <select name="action" id="action">
                       <option value="">--Actions--</option>
                       <option value="quickview" onclick="action();"> Quick View </option>
                       <option value="showmap"> Show Map</option>
                       <option value="dispatchjob"> Dispatch job </option>  
                       <input type="text" id="userid" value="<?=$r['id']?>" />
                      <!-- <input type="text" name="id" id="userid" value=<?php echo $_r['id'] ?>  />   --> 
                          </td>


                        </tr>
                        <? } ?>
                        <? } ?>
                        </tbody>
                </table>
                </div>
                </div>

                <div class="mainright">
            <div class="mainrightinner">

                <div class="widgetbox uncollapsible">
                    <div class="title"><h2 class="chat"><span>Online Drivers</span></h2></div>
                    <div class="widgetcontent padding0">
                        <!--<div class="chatsearch">
                            <input type="text" name="" value="Search" />
                        </div>-->

                 <ul class="contactlist" id="driver">
          <li class="online new"><a href="#"><img src="images/avatar.png" alt="" /><span><?= $drv['name'] ?></span></a></li>
             </ul>


                        <!--<div class="chatbottom">
                            <a href="#">+ Add Contact</a>
                        </div>-->


                    </div><!--widgetcontent-->
                </div><!--widgetbox-->

            </div><!--mainrightinner-->
        </div>


        <?php include("inc/footer.php"); ?>

        </div><!--maincontent-->
        </div><!--mainwrapperinner-->
    </div><!--mainwrapper-->
    <!-- END OF MAIN CONTENT -->


</body>


</html>

定期预订| Othminicabs.co.uk
jQuery(文档).ready(函数(){
刷新位置();
myFunction();
});
函数refreshCarLocation(){
ajax({
url:“refresh.php”,
成功:功能(响应){
jQuery('#driver').html(响应);
}           
});
} 
函数myFunction()
{
setInterval(函数(){
刷新位置()
}
,5000);
}
函数动作()
{
jQuery.ajax({
url:“ajax/tabledata.php?id=“+jQuery('#userid').val(),
})
}
常规预订表 --行动-- 快速查看 显示地图 调度作业 /> --> 在线驱动程序

您没有关闭选择按钮 第299行

你的代码

<select name="action" id="action">
<option value="">--Actions--</option>
<option value="quickview" onclick="action();"> Quick View </option>
<option value="showmap"> Show Map</option>
<option value="dispatchjob"> Dispatch job </option>  
<input type="text" id="userid" value="<?=$r['id']?>" />

--行动--
快速查看
显示地图
调度作业

有些输入具有相同的
id=“userid”
,但HTML id属性意味着
id
是唯一的。所以,只使用了其中一个输入的值。此外,所选元素的
id
也不是唯一的。 试着这样重写:

    <td>
            <select class="action" name="action-<?=$k?>">
            <option value="">--Actions--</option>
                    <option value="quickview">Quick View</option>
                    <option value="showmap">Show Map</option>
                    <option value="dispatchjob">Dispatch job</option>
            </select>
            <input type="text" name="iserid-<?=$k?>" id="userid-<?=$k?>" value="<?=$r['id']?>">
    </td>


请参阅我传递的ajax,需要HTML响应才能修复。发布refresh.phprefresh.php用于刷新页面,请参见函数操作
    <td>
            <select class="action" name="action-<?=$k?>">
            <option value="">--Actions--</option>
                    <option value="quickview">Quick View</option>
                    <option value="showmap">Show Map</option>
                    <option value="dispatchjob">Dispatch job</option>
            </select>
            <input type="text" name="iserid-<?=$k?>" id="userid-<?=$k?>" value="<?=$r['id']?>">
    </td>
<script type="text/javascript">
jQuery(function($) {
    $('select.action').bind('change', function(evt) {
        var $this = $(this);
        if($this.val() == 'quickview') {
            var id = $this.parent('td').find('input[type="text"]').val();
            jQuery.ajax('ajax/tabledata.php', {
                type: 'get',
                data: {
                    id: id
                }
            });
        }
    });
});
</script>