Page 1 of 1

Click on image to change variable

Posted: Fri Sep 12, 2008 9:45 am
by Tom McConnell
I have these variables:

$White = 'FFFFFF';
$Black = '000000';
$Grey = 'A0A0A4';
$Green = '00FF00';
$Red = 'FF0000';
$Cyan = '00FFFF';
$Yellow = 'FFFF00';
$Blue = '0000FF';
$Magenta = 'FF00FF';

$color = &$Yellow;

When page loads: $color = &$Yellow;

I have a table that looks like a bar of colors.

See: http://www.3dmypage.com/3djava/3dview_r ... d=3dmp0001 (this page may take a while to load).

When a user clicks on one of the colors (images) the variable needs to change. For example; user clicks on the color green and the variable changes: $color = $Green;

The page will probably have to refresh also.

How can I change the variable and refresh the page when a user clicks on a color (image)?

Re: Click on image to change variable

Posted: Fri Sep 12, 2008 10:08 am
by yacahuma
you get the selection by $_GET[mycolor'];


then in your code

Code: Select all

 
 
$color = (isset($_GET['color'])) ? $_GET['color'] : $Yellow;
 
 
...
 
<a href="thispage.php?color=<?=$White?>">White</a>
<a href="thispage.php?color=<?=$Black?>"> Black </a>
 
 

Re: Click on image to change variable

Posted: Fri Sep 12, 2008 1:34 pm
by Tom McConnell
Thank you very much!

:D Works great. :D Check it out if you like:
http://www.3dmypage.com/3d/114-7/Brass-Vase.php and click "View 3D Model"

P.S. I had to change: <a href="thispage.php?color=<?=$White?>">White</a> to <a href="thispage.php?color=<?=$White?></a>