• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Translate simple php to javascript

J

Jason2k1

Guest
#1
I have a picture gallery on one of my sites which displays thumbnails of all the pictures and when a picture is clicked it pops up a window with the enlarged picture in it. i currently use php to do this, but i would like to translate it into a client-side language like javascript.

the url of the page that displays the pictures is:
pictureviewer.php?src=name.jpg where name is the name of the picture.

the current code i use is this:

PHP:
<HTML>

<HEAD>

<TITLE>Picture Viewer</TITLE>

</HEAD>

<BODY bgcolor="#99cc00" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="10">

<TABLE width="100%" height="100%" border="0">

<TR><TD align="center" valign="middle">

<IMG src="images/gallery/<?php echo("$src");?>">

</TD></TR>

</TABLE>

</BODY>

</HTML>
Does anyone know how to get this to work using javascript.

Please help,

Thanks in advance

Jason
 
#2
Try this. It only works with one parameter though!

PHP:
<HTML>
<HEAD>
<TITLE>Picture Viewer</TITLE>
</HEAD>
<BODY bgcolor="#99cc00" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="10">
<TABLE width="100%" height="100%" border="0">
<TR><TD align="center" valign="middle">
<SCRIPT>
image = location.href.substring(location.href.lastIndexOf("=")+1,location.href.length);
document.writeln("<IMG src=\\"images/gallery/\\"" +  image+ ">");
</SCRIPT>
</TD></TR>
</TABLE>
</BODY>
</HTML>
 
#3
hey... if neither of you would mind, I would like to know how I might place a picture viewer on my site. I want one that would search a directory and use anything from it (JPG). I tried the code above but was unable to get it to work for me. I greatly appreciate it.
 
#4
Then you need to stick with PHP or something other server-side. You can't use Javascript anyway, no file access.

There are some free u can download (and if you wish, modify) if you look for them. www.sourceforge.net is one place to look.
 
J

Jason2k1

Guest
#5
Thanks Zedric, the script didn't work that you gave me, just a few things that i had to change and it worked. Thanks neway, i wunt of got out like that on my own seen as im only a beginner in the javascript language. Ive posted the corrected script below if anyone wants to use it:

PHP:
<HTML>
<HEAD>
<TITLE>Picture Viewer</TITLE>
</HEAD>
<BODY bgcolor="#99cc00" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="10">
<TABLE width="100%" height="100%" border="0">
<TR><TD align="center" valign="middle">
<SCRIPT>
image = location.href.substring(location.href.lastIndexOf("=")+1,location.href.length);
document.writeln("<IMG src=\"images/gallery/"+image+"\">");
</SCRIPT>
</TD></TR>
</TABLE>
</BODY>
</HTML>
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,240
Members
89,017
Latest member
keithgonzaal