Making popupwindow from html, not file

I have a php page that displays rows from mysql db as a table. One of the fields contains HTML markup and I would like this line to be clicked and the html will open in a new popup. What is the best way to do this, and is there a way to do it without writing the html to a file?

edit: this php page is actually part of the ajax application, so this is not a problem. I don't want to use jquery as I would have to rewrite the application.

edit:

I tried it again using the example below and it failed. I know the script tag is wrong, but at the moment I'm just iterating over row2, so I think my logic is wrong before it ever gets into javascript.

$sql="SELECT * FROM Auctions WHERE ARTICLE_NO ='$pk'";
$sql2="SELECT ARTICLE_DESC FROM Auctions WHERE ARTICLE_NO ='$pk'";
$htmlset = mysql_query($sql2);
$row2 = mysql_fetch_array($htmlset);
echo $row2;
/*echo '<script> child1 = window.open ("about:blank")
child1.document.write("$row2['ARTICLE_DESC']");
child1.document.close()*/

      

0


source to share


4 answers


child1 = window.open ("about:blank")
child1.document.write("Moo!");
child1.document.close()

      



+4


source


If you don't require a browser window (this suggestion is related to the css module), you may want to consider one of the "lightbox" options.



Thickbox can be used to load inline content from a page into a modal. The link provides demo / details on how to implement inline content as well as other options.

0


source


I would suggest using a Javascript library like jQuery as it simplifies this type of code and is browser compatible.

$(document).ready( function() {

$('#clicker').click( function() {
    myWindow=window.open('','','width=200,height=100')
    myWindow.document.write($("#content"));
    return false;
});

});

      

html will be:

 <table>
    <tr>
       <td><div id="clicker">Click Here</div></td>
       <td><div id="content">This is the content</div></td>
     </tr>
 </table>

      

0


source


if its a lot of data, it is worth considering loading it via ajax on view to save its selection and send it to the user on every page load - which would be pretty easy with something like jquery as already suggested.

0


source







All Articles