Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    conditional href

    Does anyone know how i could do this as a condiftional statement? I want to set a variable based on the image selected and then pass that variable as a session variable and open a page. All I want is a way to pass a value to a variable when the user clicks one of the image maps. I don't want to use a form with a submit button. Is there any other way to accomplish this?

    Thanks Art

    <map name="Map" id="Map">
    <area shape="rect" coords="732,24,817,47" href="#" />
    <area shape="rect" coords="822,24,919,48" href="#" />
    <area shape="rect" coords="924,24,1012,48" href="#" />
    </map>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    With what you have, you cannot do this with just php. PHP is pure server side, and you're href is a hash target, so thats all client side. With AJAX you could do this.
    However, if you change you're href to include an identifier for the particular image (ie: <area shape="rect" coords="w,x,y,z" href="page.php?image=uniqueVal" />), then you can detect this with the $_GET superglobal on the page.php.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If i understand correctly, i would use an intermediate page and use the value in image to detect which link was clicked? how would this be possible in ajax?

    thanks
    art

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Correct. The intermediate page could be this page with conditions though, it doesn't technically have to be a new script.
    Ajax would simply use the same page to take care of this behind the scenes. You would instead use an onclick event to pass some identifiable information to the page, get the result and do what you need to do with it. W3Schools has a pretty straight forward AJAX tutorial: http://www.w3schools.com/Ajax/Default.Asp
    Questions relating to AJAX would go under the javascript subforum for AJAX and Design. You'll need to ensure that the return result is either plain text or well formed xml.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    thanks it worked like a charm

    Art


  •  

    Posting Permissions

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