SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    String concatenation not working

    Hey,
    me again

    I got this page:
    http://web.zone.ee/testcss/

    I got this PHP script which generates a javascript array of filenames.
    Everything works fine when I add DIRNAME to the array strings in PHP,
    but if I want to concatenate the strings in this for loop, it gets weird.

    I've tried alert() both arrays when they are the same, and there is no difference there, however when the array of files (fadeimages) is supposed to get loaded into the slideshow it doesn't get displayed.

    When I look it from the Google Chrome Inspect element, the image src is the url and /i. That's the begging of the path name, but why only the first letter?

    Sorry for the wrong title, I quess the string concatenation really is working.

    Thanks

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Koora View Post

    When I look it from the Google Chrome Inspect element, the image src is the url and /i. That's the begging of the path name, but why only the first letter?
    Did you actually write fadeshow? Only this code would be responsible for your problem:
    Code:
    for (p=0;p<theimages.length;p++){
    this.postimages[p]=new Image()
    this.postimages[p].src=theimages[p][0]
    }
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't write teh slideshow script.

    Why would it be different,
    IF PHP generates the array
    Code:
    echo 'fadeimagesPHP['.$curimage.']=["'.$dirname.$file.'"];'."\n";
    It would look like this:
    Code:
    fadeimages2[0]=["img/gallery/01_2.jpg"]
    And when javascript itself generated the array, I mean, removed the $dirname, from PHP, so javascript would add var path itself before the image name.

    They look identical, I proved it with alerting both, when they were the same.
    However one is working (PHP generated), and the other isn't.

    I think the problem could be with the slideshow script,
    however it doesn't make sense, unless there is some string specific thing going on.

  4. #4
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Koora View Post
    I didn't write teh slideshow script.

    Why would it be different,
    IF PHP generates the array
    Code:
    echo 'fadeimagesPHP['.$curimage.']=["'.$dirname.$file.'"];'."\n";
    It would look like this:
    Code:
    fadeimages2[0]=["img/gallery/01_2.jpg"]
    And when javascript itself generated the array, I mean, removed the $dirname, from PHP, so javascript would add var path itself before the image name.

    They look identical, I proved it with alerting both, when they were the same.
    However one is working (PHP generated), and the other isn't.
    The script appears to be expecting a two dimensional array, but that may not be what your script is producing, even if it alerts the same.
    Tab-indentation is a crime against humanity.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •