真的需要帮助.... 我有两个脚本:
的index.php
<html>
<head><title>Select Chain</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var htmlobjek;
$(document).ready(function()
{
//apabila terjadi event onchange terhadap object <select id=region>
$("#region").change(function()
{
var region = $("#region").val();
$.ajax(
{
url: "GetMSC.php",
data: "region="+region,
cache: false,
success: function(msg)
{ //jika data sukses diambil dari server kita tampilkan
//di <select id=kota>
$("#msc").html(msg);
}
});
});
$("#sub_but").click(function()
{
$.ajax(
{
url: "ShowSCR.php",
type: GET,
data: $(this).serialize(),
cache: false,
success : function(data)
{
$("#scr").html(data);
}
});
});
});
33
</script>
</head>
<body>
<?php
include "conn.php";
include "q_table.php";
?>
<form name="scr_form" id="scr_form">
<table border="2">
<tr>
<td>
<table>
<tr>
<td>
<font size="-1">Date From<br> </font>
<input type="text" name="datefrom" id="datefrom">
<a href="javascript:void(0)" onClick="if(self.gfPop)gfPop.fPopCalendar(document.scr_form.datefrom);return false;">
<img name="popcal" align="absmiddle" style="border:none" src="./calender/calender.jpeg" width="34" height="29" border="0" alt="">
</a>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<font size="-1">Date To<br> </font>
<input type="text" name="dateto" id="dateto">
<a href="javascript:void(0)" onClick="if(self.gfPop)gfPop.fPopCalendar(document.scr_form.dateto);return false;">
<img name="popcal" align="absmiddle" style="border:none" src="./calender/calender.jpeg" width="34" height="29" border="0" alt="">
</a>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<font size="-1">Region <br></font>
<select name="region" id="region">
<option value="0" selected="selected">--Pilih Region--</option>
<option value="AllReg"> <b>All Region</b> </option>
<?php
while($p=mssql_fetch_array($q_region)){
echo "<option value=\"$p[0]\">$p[1]</option>\n";
}
?>
</select>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<font size="-1">MSC <br></font>
<select name="msc" id="msc">
<option selected="selected">--Pilih MSC--</option>
</select>
</td>
</tr>
</table>
</td>
<td align="center">
<input type="submit" value="Process" name="proses" id="sub_but">
</td>
</tr>
</table>
</td>
</form>
<br>
<div id="scr">
</div>
</body>
</html>
<!-- PopCalendar(tag name and id must match) Tags should not be enclosed in tags other than the html body tag. -->
<iframe width=174 height=189 name="gToday:normal:./calender/agenda.js" id="gToday:normal:./calender/agenda.js" src="./calender/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;">
</iframe>
ShowSCR.php
<?php
include "conn.php";
$datefrom = $_GET['datefrom'];
$dateto = $_GET['dateto'];
$region = $_GET['region'];
$msc = $_GET['msc'];
if($msc == 'AllMsc')
{
$q_msc2 = mssql_query("SELECT distinct DATE_ID, HOUR_ID, MSC, (SUM(Success_16/Attempt_16)*100) as SCR_16
FROM SCR
WHERE DATE_ID >= '$datefrom'
and DATE_ID <= '$dateto'
group by DATE_ID, HOUR_ID, MSC,Success_16,Attempt_16");
}elseif($msc != 0 or $msc != 'AllMsc')
{
$q_msc2 = mssql_query("SELECT distinct DATE_ID, HOUR_ID, MSC, (SUM(Success_16/Attempt_16)*100) as SCR_16
FROM SCR
WHERE msc_id='$msc'
AND DATE_ID >= '$datefrom'
AND DATE_ID <= '$dateto'
group by DATE_ID, HOUR_ID, MSC,Success_16,Attempt_16");
}
echo "$datefrom";
echo "$dateto";
echo "$region";
echo "$msc";
echo "
<table border='2' width='50%'>
<tr align='center'>
<td><b>Date</b></td>
<td><b>Time</b></td>
<td><b>MSC</b></td>
<td><b>SCR 16bit(%)</b></td>
</tr>";
while($k = mssql_fetch_array($q_msc2))
{
$date_1 = date("Y-m-d", strtotime($k[DATE_ID]));
echo "
<tr>
<td align='center'><font size='-1'>$date_1</font></td>
<td align='center'><font size='-1'>$k[HOUR_ID]</font></td>
<td align='center'><font size='-1'>$k[MSC]</font></td>
<td align='center'><font size='-1'>$k[SCR_16]</font></td>
</tr>
";
}
echo "</table>";
?>
index.php中的提交数据表单无法发送到ShowSCR.php。 我已经尝试根据按钮或表单更改函数名称,但是它仍然不起作用...
答案 0 :(得分:0)
您正在通过AJAX传递$(this).serialize()
,但请注意this
代表的内容。在这里,它是你点击的按钮。您需要获取该按钮所属的表单,并序列化 。