我想在选择相应的下拉列表时通过 ajax 发送 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" /> <strong>New</strong>
</td>
<td>
<img src="images/reddot.png" class="imgg" /> <strong>Cancelled</strong>
</td>
<td>
<img src="images/yellowdot.png" class="imgg" /> <strong>Confirmed</strong>
</td>
<td>
<img src="images/browndot.jpg" class="imgg" /> <strong>Pending</strong>
</td>
<td>
<img src="images/blackdot.png" class="imgg" /> <strong>Posponed</strong>
</td>
<td>
<img src="images/greendot.png" class="imgg"/> <strong>Confirmed Operator</strong>
</td>
<td>
<img src="images/greendot.png" class="imgg"/> <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"> </th>
<th class="head0"> </th>
<th class="head1"> </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"> </th>
<th class="head0"> </th>
<th class="head1"> </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>