Skip navigation
Smohren
Currently Being Moderated

Adding a passed parameter to a image pathway

Nov 19, 2012 3:56 PM

Tags: #cs5 #images #pass #parameter

I am using dreamweaver CS5 and I have a web page that passes a 4 letter code to another web page that contains images.  I want to include the 4 letter code in the pathway of the image shown on the web page, is this possible?

 

For example, lets say a person uses a pick list and picks "TFFA" and hits submit.  TFFA is passed to another web page.  All of this works fine.  Now what I want to do is add "TFFA" to the pathway for the image.  So in the example below you will see TFFA is actually part of the image name.  All of the images are named the same with the exception of the first 4 letters which is dependent on the value a person picks from the previous web page.

 

Thanks

 

 

 

<li>

                      <span class="style16">Point 01</span><a href="images/TFFA01_2009.jpg" title=""><img src="TFFA01_2009_Thumb.jpg" width="160" height="106" alt="Flower" /></a>

                    </li>

 
Replies
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Nov 19, 2012 9:17 PM   in reply to Smohren

    Now what I want to do is add "TFFA" to the pathway for the image.

    Can you please be more descriptive? I don't quite understand 'pathway for the image' bit.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 19, 2012 9:59 PM   in reply to Sudarshan Thiagarajan

    I took it to mean that the OP wants a variable in the image path to dynamically alter the path name depending on the option selected in the pick list.

     

    Selecting TFFA would modify the path in the code as

     

    <a href="images/TFFA01_2009.jpg" title=""><img src="TFFA01_2009_Thumb.jpg" width="160" height="106" alt="Flower" /></a>

     

    Selecting TFFB would modify the path in the code as

     

    <a href="images/TFFB01_2009.jpg" title=""><img src="TFFB01_2009_Thumb.jpg" width="160" height="106" alt="Flower" /></a>

     

    Easily done with PHP



     
    |
    Mark as:
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Nov 20, 2012 8:29 AM   in reply to Smohren

    Do you only have a limited number of images or do you have many of them? The reason I ask - if you have only a limited number of them, you could do a string validation and pass that to the page which will load the image. If you have way too many of them, you should ideally consider building a control panel to ensure there are no errors that arise in the long term.

     

    BTW, I'm moving this thread to 'Developing server-side applications in Dreamweaver' for better responses.

     

    -ST

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 23, 2012 5:43 AM   in reply to Smohren

    As John says, this is easily done with PHP. To ensure that the value passed through the URL is valid (and not an attempt to probe the file system), you would need to create an array of acceptable values at the top of the page. Assuming the variable is passed on the end of the URL as ?cat=TFFA (or whatever value is chosen), it would look like this:

     

    <?php

    $valid = array('TFFA', 'LAVO', 'CRLA', 'LABE');

    if (in_array($_GET['cat'], $valid)) {

        $prefix = $_GET['cat'];

    } else {

        $prefix = 'TFFA';

    }

    ?>

     

    This checks whether the value passed through the URL is in the $valid array. If it is, it's assigned to $prefix. If it's not, $prefix is given a default value to prevent errors.

     

    Then, in the body of the page, the value of $prefix is used like this:

     

    <a href="images/<?php echo $prefix; ?>01_2009.jpg" title=""><img src="<?php echo $prefix; ?>01_2009_Thumb.jpg" width="160" height="106" alt="Flower" /></a>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points