/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Open image in new window (javascript + PHP)

using this code, how can I change the javascript function name from load to load1(), load2()….

my user(s) can upload photos, and this javascript opens the photos up in a new window, but the photos all have href=”javascript:load()” this will make all the windows the size, with the same image. I want it to display the correct image, using the right function to open the window.

[code=php]$files = glob(‘images/photos/*.*’);
if(count($files))
{
echo ‘<table>’;
if (isset($_SESSION[user])){
echo ‘<form action=”index.php?page=delete” method=”post”><tr>’;
}
$counter = 0;
foreach($files as $path)
{
if(!(++$counter % 4))
{
echo “</tr>n<tr>”;
}
$image = “$path”;
$size = GetImageSize($image);
$width=$size[0];
$height=$size[1];
$filename = basename($path);
$directory = dirname($path);
$width=$width + 20;
$height=$height + 20;

echo”
<Script Language=”JavaScript”>
function load() {
var load = window.open(‘$path’,”,’scrollbars=yes,menubar=no,height=$height,width=$width,resizable=no,toolbar=no,location=no,status=no’);
}
</Script>
“;
echo “<td><a href=’javascript:load()’ alt=”><img border=’0′ src=’$directory/thumbs/$filename’></a>”;
if (isset($_SESSION[user])){
echo ‘<br><input type=”checkbox” name=”delete[]” value=”‘.$filename.'”> Delete Photo’;

}

echo”</td>n”;
}
if (isset($_SESSION[user])){
echo ‘</tr><tr><td colspan=”3″><input type=”submit” value=”Delete”></td></tr></form></table>’;
}else{
echo”</table>”;
}
} [/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @The_Little_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...