jQuery UI对话框中的动态PHP页面

时间:2012-11-08 11:16:24

标签: php jquery-ui jquery-ui-dialog

我有一个通过PHP& amp; MS-SQL显示我们客户持有的股票清单(我在股票经纪人中工作)。简化表如下所示:


    | + | Google |
    | + | Apple |
    | + | Microsoft |

加号是一个图像,当我点击它时,它会弹出一个jQuery对话框。这部分工作正常,但目前每个对话框都显示静态数据。我现在需要的是对话框显示另一个表格,显示每个股票的交易。

这是我到目前为止的Javascript:

<script>
 $(function() {

  $('div.dialog')
  .dialog(
    {
        autoOpen: false,
        modal: true
    }
    );

  $('img.opener')
  .css("cursor","pointer")
  .click(function()
    {
        $('#' + this.id.replace(/opener/, 'dialog'))
        .dialog('open');
        return false;
        }
    );
 });
</script>

用PHP创建表:

<?php                               

  echo '<tr>';
    echo '<td><img id="opener' . $row_counter . '" class="opener" src="../images/procedural/plus-white.png" title="Click to show Transactions"></td>';
    echo '<td align=left>' . htmlentities($stock_short_name) . '</td>';
    echo '<td style="display: none"><div id="dialog' . $row_counter . '" class="dialog" title="Transactions for ' . $stock_sedol . '">This is box ' . $row_counter . '</div></td>';
  echo '</tr>';

?>

我发现这个脚本我已经修改了一些,以便从另一个PHP文件中恢复我想要的内容:

<!doctype html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Animation</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
  $('#tire-specs th a').each(function() {
    var $link = $(this);
    var $dialog = $('<div></div>')
    .load($link.attr('href') + ' #content')
    .dialog({
        autoOpen: false,
        title: $link.attr('title'),
        width: 600
    });

  $link.click(function() {
    $dialog.dialog('open');

    return false;
    });
  });
});
</script>

</head><body>


<table id="tire-specs">
  <thead>
    <tr>
      <th>Size</th>
      <th><a href="trans.php?client=62629&stock=34935" title="Transactions">Transactions</a></th>
      <th>Max Load</th>
      <th>Max Inflation Pressure</th>
      <th>Tread Depth</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>205/65R15</td>
      <td>620 A A</td>
      <td>1477 lbs.</td>
      <td>44 psi</td>
      <td>11/32"</td>
    </tr>
  </tbody>
</table>

</body></html>

这是trans.php:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Transactions</title>
</head>
<body>
<h1>Transactions</h1>

<div id="content">

<?php

  $client=$_GET["client"];
  $stock=$_GET['stock'];

  $mssql_server= "sql-primary";
  $mssql_database = "FOUR_I_CORE";

  include("../index_files/mssql_include.php");

  $sql = "SELECT * FROM [TRA_CORE] WHERE [CLIENT REC NO] = '$client' AND [STOCK REC NO] = '$stock' AND [QUANTITY] != 0";
  $stmt = sqlsrv_query($connnection, $sql);

            while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))

                {

                    $cost = $row['COST/PROCEEDS'];

                    echo $cost . '<br>';

                }

?>

</div>

</body>
</html>

但是,我无法弄清楚如何使第二个脚本与第一个脚本集成,因此每个对话框都是动态的。有人可以帮忙吗?

(很抱歉这篇冗长的帖子,更多的信息比没有更好)

干杯, 戴夫

0 个答案:

没有答案