Jump to content

Recommended Posts

I have a while loop that displays all files associated with a project that display in a table. I want to use a button to open those files in a popup. My problem is that all the buttons (one generates per file), open the same file instead of their respective files, which is the first file displayed. If I do use a simple link (href), I can open the correct file, but it doesn't display in a popup, which is a problem. Does anyone have any suggestions on how to use a link or button to open the correct files in a  popup? Below is my code:

 

<?
"<table border='1' cellspace='10'>\n".
"<BR><BR>\n".
"<tr><th align='center' colspan='5'><font size'4'>Stored Documents</font></th></tr>\n".
"<tr><th align=center width='300'>Date Added</th>\n".
"<th align=center width='450'>Document Title</th>\n".
"<th align=center width='450'>File Name</th>\n".
"<th colspan='2'>&nbsp</th>\n".
"</tr>\n";

While(list($date, $filename, $title) =  mysql_fetch_array($resultd)) {

echo
"<tr>\n".
"<td align=center>$date</td>\n".
"<td align=center>$title</td>\n".
"<td align=center><a href='docs/$coid/$filename'>$filename</a></td>\n".
"<td align=center><input type='hidden' value='$filename' name='file_name'></input></td>\n".
"<td align=center><input type='button' value='View Docs' onclick='return docview(); return false'>\n".
"</tr>\n".
}

"</table>\n";
?>

<!-- Document open
var filename = document.getElementById("file_name").value;
var compid = document.getElementById("comp_id").value;

function docview(url) {
newwindow = window.open('/'+'docs/'+compid+ '/' +filename,'DocViewer','width=800,height=600,top=150,left=350,scrollbars=1,status=1');
if (window.focus) {newwindow.focus()}
return false;
}
//--> </script> 

Link to comment
https://forums.phpfreaks.com/topic/268130-whileloop-popup-issue/
Share on other sites

I have a while loop that displays all files associated with a project that display in a table. I want to use a button to open those files in a popup. My problem is that all the buttons (one generates per file), open the same file instead of their respective files, which is the first file displayed. If I do use a simple link (href), I can open the correct file, but it doesn't display in a popup, which is a problem. Does anyone have any suggestions on how to use a link or button to open the correct files in a  popup? Below is my code:

 

<?
"<table border='1' cellspace='10'>\n".
"<BR><BR>\n".
"<tr><th align='center' colspan='5'><font size'4'>Stored Documents</font></th></tr>\n".
"<tr><th align=center width='300'>Date Added</th>\n".
"<th align=center width='450'>Document Title</th>\n".
"<th align=center width='450'>File Name</th>\n".
"<th colspan='2'>&nbsp</th>\n".
"</tr>\n";

While(list($date, $filename, $title) =  mysql_fetch_array($resultd)) {

echo
"<tr>\n".
"<td align=center>$date</td>\n".
"<td align=center>$title</td>\n".
"<td align=center><a href='docs/$coid/$filename'>$filename</a></td>\n".
"<td align=center><input type='hidden' value='$filename' name='file_name'></input></td>\n".
"<td align=center><input type='button' value='View Docs' onclick='return docview(); return false'>\n".
"</tr>\n".
}

"</table>\n";
?>

<!-- Document open
var filename = document.getElementById("file_name").value;
var compid = document.getElementById("comp_id").value;

function docview(url) {
newwindow = window.open('/'+'docs/'+compid+ '/' +filename,'DocViewer','width=800,height=600,top=150,left=350,scrollbars=1,status=1');
if (window.focus) {newwindow.focus()}
return false;
}
//--> </script> 

The first part of your code does nothing, because you don't save it to a variable or print it to screen... o.O

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.