Get a piece of the filename with javascript

Discussion in 'JavaScript' started by Sipifi, Jan 17, 2009.

  1. #1
    Hey all,

    I have a website for friends and family with all images on it. First there's the main page with all thumbs on it. When clicked you will see the image in a page with image.php?id= in the url.

    All the image file have a set of numbers, then the name and the extension so like this: 54785imagename.jpg

    Is there a way i can just take the numbers out of that file name from the url so that i can use it further down the page? For a comment script or something else i would like to add. So that i wouldn't have to do it manually for every image.

    Hope you get what i mean :p

    Thanks for reading

    /Sipifi
     
    Sipifi, Jan 17, 2009 IP
  2. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #2
    are all the images in the same directory? If so, we can just read the dir and pull out all the file names to use.
     
    crath, Jan 17, 2009 IP
  3. Sipifi

    Sipifi Well-Known Member

    Messages:
    530
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    155
    #3
    They are. Reading all the file names on one single page that displays 1 image or?
     
    Sipifi, Jan 17, 2009 IP
  4. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #4
    no, read the directory with php, so that you can output the links however you need.

    can you link me to this page?
     
    crath, Jan 17, 2009 IP
  5. Sipifi

    Sipifi Well-Known Member

    Messages:
    530
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    155
    #5
    I worked it out with something else than javascript already :) Thanks for your time though. I appriciate it a lot.
     
    Sipifi, Jan 18, 2009 IP