Log in

View Full Version : dhtmlwindow.open if else linking



tooletime
10-14-2010, 07:04 PM
i need help bad. It might be an easy fix but i cant figure it out to save my life.

Here is what i am trying to accomplish. I want to show a link if a file exists on a remote server. That part works. The problem i am having is having the link actually open the dhtml window when the link appears.

Its in php 5.3 now

The script that works is this:

[ICODE]<a href='#' onClick="readmewin=dhtmlwindow.open('README', 'iframe', 'file:////bas-vm01/iso/docs/CM11886.pdf', 'README for CM<?php echo $row_Master_Detail_Recordset['ID']; ?>.pdf ', 'width=500px,height=300px,center=1, resize=1'); return false">README</a>;[ICODE]

so that link opens up the window and shows me the pdf. WONDERFUL!! :)

Now the part that i need to work
[CODE]
<?php

$id = $_GET['ID'];
$path = '//bas-vm01/iso/docs/cm';
$filename= $path.$id.'.pdf';


if (file_exists($filename))

echo '<a href="#" onClick="readmewin=dhtmlwindow.open(\'readme\', \'iframe\', \'$filename\', \'README for CM<?php echo $row_Master_Detail_Recordset[\'ID\']; ?>.pdf \', \'width=500px,height=300px,center=1, resize=1\'); return false">README</a>';

else
echo "The file $filename does not exist";
?>
[CODE]

So the link shows up if the file exists or the else statements shows up. So that part works.

The part that doesn't work is the link to the dhtml window.

PLEASE HELP!!! its gotta be something simple im sure LOL

bluewalrus
10-14-2010, 07:52 PM
Your already in the php block and echoing so remove the <?php echo and the ?>.


echo '<a href="#" onClick="readmewin=dhtmlwindow.open(\'readme\', \'iframe\', \'$filename\', \'README for CM' . $row_Master_Detail_Recordset['ID'] . '.pdf \', \'width=500px,height=300px,center=1, resize=1\'); return false">README</a>';

tooletime
10-14-2010, 08:02 PM
HOLY COW!!! dang that was fast!!!

and yes see!!! it was something so freakin simple.... LOL

Bluewalrus You get a million points today... :D

THANK YOU THANK YOU THANK YOU!!! :D

FINAL CODE
[CODE]
<?php

$id = $_GET['ID'];
$path = '//bas-vm01/iso/docs/cm';
$href = 'href="#"';
$filename= $path.$id.'.pdf';

if (file_exists($filename))
{
echo '<a href="#" onClick="readmewin=dhtmlwindow.open(\'readme\', \'iframe\', \'file:////bas-vm01/iso/docs/CM' . $row_Master_Detail_Recordset['ID'] . '.pdf \', \'README for CM' . $row_Master_Detail_Recordset['ID'] . '.pdf \', \'width=800px,height=600px,center=1, resize=1\'); return false">README</a>';
}
else {

}
?>
[CODE]