我有一个下拉字段,我有2个选项(速率高和速率低)当我选择速率高时它应该按降序显示结果或如果我选择速率低它应该按升序显示结果我试过一个无效的代码。
我的HTML代码是:
<select id="ddlViewBy" onchange="order()">
<option value="high">Rate(high)</option>
<option value="low">Rate(low)</option>
</select>
我的JavaScript代码是:
function order() {
var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].value;
if(strUser == 'high')
{
<?php
$post->id="10";
$mylink = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_biddings WHERE job_id = %d ORDER BY client_bill DESC", $post->id), ARRAY_A);
if($_GET['bid_id'])
{
foreach ( $mylink as $row )
{
$id= $row['user_id'];
$nam=$row["name"];
$stat=$row['state'];
$cnty=$row['country'];
$desc=$row["description"];
$bid=$row['id'];
$dat=$row['submission_date'];
echo '<a href="../../wp-content/themes/businessfinder/profile_register.php?id=$id&view" target="_blank">';
echo "<div class='mr-btm' style='width:98%'>";
echo "<h3 style='text-transform:uppercase; line-height:0'><b>$name</b></h3>";
echo "<p style='color:#808080; text-transform:uppercase;'>$stat,$cnty</p>";
echo "<p style='color:#808080;'>$desc</p>";
echo "<date style='color:#35cbc9;'>categories : </date>";
echo "<date style='color:#808080;'>";
if($row["plumbing"] != '')
echo $row["plumbing"];
if($row["electrical"] != '')
echo $row["electrical"];
if($row["heating"] != '')
echo ",".$row["heating"];
if($row["ventilation"] != '')
echo ",".$row["ventilation"];
if($row["flooring"] != '')
echo ",".$row["flooring"];
echo ".</date>";
echo "<table class='btm-cm'><tr><td>";
echo "<date style='color:#35cbc9;'> Id : </date><date style='color:#808080;'>$bid</date> </td> <td style='color:#35cbcp;'> | </td><td>";
echo "<date style='color:#35cbc9;'> submitted on: </date><date style='color:#808080;'>$dat</date></td></tr></table></div></a>";
}
}
else
{
echo "nothing found";
}
}
?>
}
else if(strUser == 'low')
{
<?php
$post->id="10";
$mylink = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_biddings WHERE job_id = %d ORDER BY client_bill ASC", $post->id), ARRAY_A);
if($_GET['bid_id'])
{
foreach ( $mylink as $row )
{
$id= $row['user_id'];
$nam=$row["name"];
$stat=$row['state'];
$cnty=$row['country'];
$desc=$row["description"];
$bid=$row['id'];
$dat=$row['submission_date'];
echo '<a href="../../wp-content/themes/businessfinder/profile_register.php?id=$id&view" target="_blank">';
echo "<div class='mr-btm' style='width:98%'>";
echo "<h3 style='text-transform:uppercase; line-height:0'><b>$name</b></h3>";
echo "<p style='color:#808080; text-transform:uppercase;'>$stat,$cnty</p>";
echo "<p style='color:#808080;'>$desc</p>";
echo "<date style='color:#35cbc9;'>categories : </date>";
echo "<date style='color:#808080;'>";
if($row["plumbing"] != '')
echo $row["plumbing"];
if($row["electrical"] != '')
echo $row["electrical"];
if($row["heating"] != '')
echo ",".$row["heating"];
if($row["ventilation"] != '')
echo ",".$row["ventilation"];
if($row["flooring"] != '')
echo ",".$row["flooring"];
echo ".</date>";
echo "<table class='btm-cm'><tr><td>";
echo "<date style='color:#35cbc9;'> Id : </date><date style='color:#808080;'>$bid</date> </td> <td style='color:#35cbcp;'> | </td><td>";
echo "<date style='color:#35cbc9;'> submitted on: </date><date style='color:#808080;'>$dat</date></td></tr></table></div></a>";
}
}
else
{
echo "nothing found";
}
}
?>
}
}
</script>
答案 0 :(得分:0)
将php视为一封信的作者,然后将其放入信封中并将蜗牛邮寄添加到浏览器中。浏览器打开它,读取它并运行指令。该信函的作者一旦发布,就无法添加更多内容。
换句话说,PHP是在服务器端执行的,javascript是在客户端执行
您想要查看ajax。
以下是manual让您入门