Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic PHP pages in jQuery UI dialog box
    primarykey
    data
    text
    <p>I have a table that is built via PHP &amp; MS-SQL that shows a list of stocks that our clients hold (I work in a stockbrokers). The simplified table looks like this:</p> <pre> | + | Google | | + | Apple | | + | Microsoft | </pre> <p>The plus sign is an image, and when I click it, it brings up a jQuery dialog box. This part works fine, but at the moment each dialog displays static data. What I need now is for the dialog to display another table, that shows the transactions for each stock.</p> <p>Here's the Javascript I have so far:</p> <pre><code>&lt;script&gt; $(function() { $('div.dialog') .dialog( { autoOpen: false, modal: true } ); $('img.opener') .css("cursor","pointer") .click(function() { $('#' + this.id.replace(/opener/, 'dialog')) .dialog('open'); return false; } ); }); &lt;/script&gt; </code></pre> <p>And the PHP to create the table:</p> <pre><code>&lt;?php echo '&lt;tr&gt;'; echo '&lt;td&gt;&lt;img id="opener' . $row_counter . '" class="opener" src="../images/procedural/plus-white.png" title="Click to show Transactions"&gt;&lt;/td&gt;'; echo '&lt;td align=left&gt;' . htmlentities($stock_short_name) . '&lt;/td&gt;'; echo '&lt;td style="display: none"&gt;&lt;div id="dialog' . $row_counter . '" class="dialog" title="Transactions for ' . $stock_sedol . '"&gt;This is box ' . $row_counter . '&lt;/div&gt;&lt;/td&gt;'; echo '&lt;/tr&gt;'; ?&gt; </code></pre> <hr/> <p>I've found this script which I've modified a bit to bring back what I want from another PHP file:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;jQuery UI Dialog - Animation&lt;/title&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.8.2.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#tire-specs th a').each(function() { var $link = $(this); var $dialog = $('&lt;div&gt;&lt;/div&gt;') .load($link.attr('href') + ' #content') .dialog({ autoOpen: false, title: $link.attr('title'), width: 600 }); $link.click(function() { $dialog.dialog('open'); return false; }); }); }); &lt;/script&gt; &lt;/head&gt;&lt;body&gt; &lt;table id="tire-specs"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Size&lt;/th&gt; &lt;th&gt;&lt;a href="trans.php?client=62629&amp;stock=34935" title="Transactions"&gt;Transactions&lt;/a&gt;&lt;/th&gt; &lt;th&gt;Max Load&lt;/th&gt; &lt;th&gt;Max Inflation Pressure&lt;/th&gt; &lt;th&gt;Tread Depth&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;205/65R15&lt;/td&gt; &lt;td&gt;620 A A&lt;/td&gt; &lt;td&gt;1477 lbs.&lt;/td&gt; &lt;td&gt;44 psi&lt;/td&gt; &lt;td&gt;11/32"&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>And here is trans.php:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Transactions&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Transactions&lt;/h1&gt; &lt;div id="content"&gt; &lt;?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 . '&lt;br&gt;'; } ?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>However, I can't work out how to make this second script integrate with the first, so that each dialog box is dynamic. Can anyone help?</p> <p>(Sorry for the lengthy post, figured more info was better than none)</p> <p>Cheers, Dave</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload