Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-16-2010, 03:05 AM   PM User | #1
aikiart
New to the CF scene

 
Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
aikiart is an unknown quantity at this point
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>
aikiart is offline   Reply With Quote
Old 02-16-2010, 05:21 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-16-2010, 12:04 PM   PM User | #3
aikiart
New to the CF scene

 
Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
aikiart is an unknown quantity at this point
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
aikiart is offline   Reply With Quote
Old 02-16-2010, 12:46 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-17-2010, 10:59 AM   PM User | #5
aikiart
New to the CF scene

 
Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
aikiart is an unknown quantity at this point
Thanks

thanks it worked like a charm

Art
aikiart is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:45 AM.


Advertisement
Log in to turn off these ads.