Jump to content


PHP and Javascript

  • Please log in to reply
4 replies to this topic

#1 k3Bobos

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 March 2006 - 10:25 PM

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 :-


Any pointers would be VERY appreciated!

Thanks in advance.

#2 AndyB

  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 10 March 2006 - 10:40 PM

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.
Legend has it that reading the manual never killed anyone.
My site

#3 txmedic03

  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 11 March 2006 - 01:18 AM

[a href=\"http://www.php.net/manual/en/function.urlencode.php\" target=\"_blank\"]This[/a] might help.


I can't stop you from doing something silly, but at least I can help you do it right.

#4 k3Bobos

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 March 2006 - 11:30 AM

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! :)

#5 k3Bobos

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 13 March 2006 - 08:19 PM

Thanks guys........got there in the end - still harder than I was expecting............

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users