我想自动显示所选选项,应选择所选选项,但既未选择所选选项,也未显示结果。
<html>
<head>
<title>Untitled</title>
</head>
<body>
<table>
<tr>
<td>Name</td>
<td width="151">
<select id="jumpMenu" onChange="MM_jumpMenu(this.value)">
<option value="">--Select Genre--</option>
<option value="Action/Mission">Action</option>
<option value="Racing">Racing</option>
</select></td>
</tr>
<tr>
<script type="text/javascript">
$(document).ready(function() {
function MM_jumpMenu(eee){
var val = document.getElementById("jumpMenu").value;
if(val=="")
{
<?php $abc=mysql_query("select * from games order by game ASC"); ?>
}
if(val=="Racing")
{
<?php $abc=mysql_query("select * from games where genre='Racing' order by game ASC"); ?>
}
if(val=="Action/Mission")
{
<?php $abc=mysql_query("select * from games where genre='Action/Mission' order by game ASC"); ?>
}
});
});
</script>
<?php
while($row=mysql_fetch_array($abc))
{
?>
<td><?php echo $row['game']; ?></td>
<td><?php echo $row['genre']; ?></td>
</tr>
<?php } ?>
</table>
</body>
</html>
问题出在哪里?
答案 0 :(得分:0)
请注意JS
是客户端,PHP
是服务器端。你不能像你想要的那样将两者结合在一起。但是,您可以使用ajax调用服务器并运行PHP
脚本接收并使用JS
中的响应。