
September 19th, 2012, 09:35 AM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 1
Time spent in forums: 28 m 4 sec
Reputation Power: 0
|
|
|
Other - Trouble passing variables to popup from php while loop
I have a while loop that displays all files associated with a project that display in a table. A project can have one file or 100 associated. I want to use a button to open those files in a popup. My problem is that all the buttons, open the same file instead of their respective files, which is the first file displayed(the variables passed to the popup never change). If I do use a simple link (href) in the php code, I can open the correct file, but it doesn't display in a popup, it opens in the same window 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:
Code:
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 Document" onclick="return viewdoc(); return false">
<?
echo
"<td align=center><input type='button' value='Delete Document' name='file_delete'></input></td>\n".
"</tr>\n";
}
echo
"</table>\n".
"<br><br><INPUT TYPE='submit' NAME='submit' VALUE='Submit'></p>\n".
"<input type='hidden' name='comp_id' value='$coid'>\n".
"</FORM>\n".
"</BODY>\n".
"</HTML>\n";
?>
<script type="text/javascript" language="javascript">
<!-- Document open
function viewdoc() {
var filename = document.getElementById("file_name").value;
var compid = document.getElementById("comp_id").value;
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;
}
|