繁体   English   中英

双击td时如何在警报框中将数据库中的数据显示为html表

[英]How to show the data from database in a alert box as html table when td is double clicked

我试图在 HTML 表中显示数据库中的数据,我想在双击td时在警报框中显示此 html 表,现在它在双击td时在警报框中显示数据,但是不像 html 表那样显示(注意:现在它在警报框中显示数据而不是 html 格式),下面是我的代码。

阿贾克斯

$('td').dblclick(function() {                

      $.ajax({    //create an ajax request to load_page.php
        type: "GET",
        url: "supplierprice/retrieve.php",             
        dataType: "html",   //expect html to be returned                
        success: function(response){                    
            $("#responsecontainer").html(response); 
          alert(response);
        }

    });
});

HTML

echo '  <td id="alertShow" width="114px;" class="edit region '.$rows["supp_price_id"].'">'.$rows["region"].'</td>
        <td id="alertShow" width="115px;" class="edit country '.$rows["supp_price_id"].'">'.$rows["country"].'</td>
        <td id="alertShow" width="286px;" class="edit networkname '.$rows["supp_price_id"].'">'.$rows["networkname"].'</td>
        <td id="alertShow" width="92px;"  class="edit mcc '.$rows["supp_price_id"].'">'.$rows["mcc"].'</td>  
        <td id="alertShow" width="94px;"  class="edit mnc '.$rows["supp_price_id"].'">'.$rows["mnc"].'</td>
        <td id="alertShow" width="92px;" class="edit mnp '.$rows["supp_price_id"].'">'.$rows["mnp"].'</td>';

检索.php

include"config.php";
$result=mysql_query("select * from supplierpricehistory");

echo "<table border='1' >
<tr>
<td align=center> <b>supplier</b></td>
<td align=center><b>country</b></td>
<td align=center><b>networkname</b></td>
<td align=center><b>mcc</b></td></td>
<td align=center><b>mnc</b></td>
<td align=center><b>newprice</b></td>       
<td align=center><b>oldprice</b></td>       
<td align=center><b>status</b></td>     
<td align=center><b>date</b></td>           
<td align=center><b>user</b></td>";

while($data = mysql_fetch_row($result))
{   
    echo "<tr>";
    echo "<td align=center>$data[1]</td>";
    echo "<td align=center>$data[2]</td>";
    echo "<td align=center>$data[3]</td>";
    echo "<td align=center>$data[4]</td>";
    echo "<td align=center>$data[5]</td>";
    echo "<td align=center>$data[6]</td>";
    echo "<td align=center>$data[7]</td>";
    echo "<td align=center>$data[8]</td>";
    echo "<td align=center>$data[9]</td>";
    echo "<td align=center>$data[10]</td>";

    echo "</tr>";
}
echo "</table>";

任何人都可以指导我如何做到这一点,或者有任何其他方法可以做到这一点。 谢谢

无法格式化标准的 js 警报。 您应该使用自定义对话框,例如http://jqueryui.com/dialog/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM