クライアントが保有する株式のリストを示す PHP と MS-SQL を介して作成されたテーブルがあります (私は株式仲買人で働いています)。簡略化した表は次のようになります。
| | + | グーグル| | | + | りんご | | | + | マイクロソフト |
プラス記号はイメージで、クリックすると 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>
ただし、この 2 番目のスクリプトを最初のスクリプトと統合して、各ダイアログ ボックスが動的になるようにする方法がわかりません。誰でも助けることができますか?
(長い投稿で申し訳ありませんが、情報がないよりはましだと考えました)
乾杯、デイブ