Jump to content

Archived

This topic is now archived and is closed to further replies.

k3Bobos

PHP and Javascript

Recommended Posts

I'm reasonably new to both PHP and Javascript (Microsoft background.......I know, it's my own fault!) but have managed to get my galleries up and running using PHP.

Now I want to call a javascript open.window function passing it the image file name and size.

All goes well until my image filename has a space in it............. (no, I can't just remove them)

I've tried every combination of ' and " and building variables rather than putting it all in-line, to no avail.

This is the last attempt before I threw the PC out the window :-

$varbuildit= "loc=$base$dir&image=$dirm$imagetext[0]";
$varahref ="javascript:OpenPage('./disp-JS.php?$varbuildit','window1',$width,$height)";

need to pass (as an example)

javascript:OpenPage('./disp-JS.php?loc=./pics/big/&image=./pics/medium/Hello World.jpg','window1',600,400)

What is does is try this :-

javascript:OpenPage('./disp-JS.php?loc=./pics/big/&image=./pics/medium/Hello

Any pointers would be VERY appreciated!

Thanks in advance.

Share this post


Link to post
Share on other sites
replace the spaces in file names (aaaarrrghhh) with their equivalent as far as javascript is concerned %20

simple str_replace function in php would handle that before passing the 'new' name to js.

Share this post


Link to post
Share on other sites
[a href=\"http://www.php.net/manual/en/function.urlencode.php\" target=\"_blank\"]This[/a] might help.

Share this post


Link to post
Share on other sites
I'll have at these later today (6 year old and 4 month old daughters will take most of the day up!!!) and let you know.

Thanks for your help - should have realised that - DOH! :)

Share this post


Link to post
Share on other sites
Thanks guys........got there in the end - still harder than I was expecting............

Share this post


Link to post
Share on other sites

×

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.