drgweamoi473182981 2013-09-07 13:43
浏览 68
已采纳

PHP:onClick不工作

My button "VIEW" is not going to the form of "booking_content.php" instead its just refreshing the page of "home.php"

Here's my code:

$radio = mysql_query("SELECT fldBldgName, MAX(fldTotalDuration) as fldTotalDuration FROM tbldata WHERE fldNetname = '".$get_radio."' AND fldMonth = '".$get_month."' AND fldWeek = '".$get_week. "' GROUP BY fldBldgName ORDER BY id, fldBldgName, fldTotalDuration DESC");

echo "<table class = 'tblMain'>";
echo "<tr align='left'>";
echo "<td><b><u>BUILDING NAME</u></b></td>";
while ($row = mysql_fetch_array($radio))
{   
echo "<tr><td align='left'>";   
echo $row['fldBldgName']."'>";

echo "<input type='image'  src='image/view.png' name='viewBldg' onClick='this.form.action='booking_content.php'; this.form.submit()'>";
echo $row['fldBldgName'];
}
echo "</tr></table>";

My problem is this one:

  echo "<input type='image'  src='image/view.png' name='viewBldg' onClick='this.form.action='booking_content.php'; this.form.submit()'>";   

*The onClick is not going to the page of booking_content.php instead its just refreshing the page...

I can't upload an example result of my program...

Please click this link so you can view my sample program: http://postimg.org/image/wbiigechn/

ALSO the code for my button is inside of a fieldset...

  • 写回答

2条回答 默认 最新

  • dtip91401 2013-09-07 13:47
    关注

    Your attempt will generate the following HTML:

    <input type='image' src='image/view.png' name='viewBldg' 
    onclick='this.form.action='booking_content.php'; this.form.submit()'>
    

    So your browser wont be able to interpret the onclick attribute correctly, because the ' before booking_content. Try the following:

    echo "<input type='image' src='image/view.png' name='viewBldg' 
    onclick=\"this.form.action='booking_content.php'; this.form.submit()\">";
    

    Which should generate a valid HTML such as:

    <input type='image' src='image/view.png' name='viewBldg' 
    onclick="this.form.action='booking_content.php'; this.form.submit()">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 经gamit解算的cors站数据再经globk网平差得到的坐标做形变分析
  • ¥15 GD32 SPI通信时我从机原样返回收到的数据怎么弄?
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!