Load $_SERVER['PHP_SELF'] with rollover image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Load $_SERVER['PHP_SELF'] with rollover image

Post by ljCharlie »

Is there a way to use a rollover menu to do a $_SERVER['PHP_SELF'] and also send along a hidden value that tells me which rollover menu button was click by a user?

Below is my rollover menu button codes generated in Adobe Image Ready.

Code: Select all

<table id="Table_01" width="165" height="35" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<img name="galleryMenus_01" src="images/galleryMenus_01.gif" width="165" height="35" border="0" alt="" usemap="#galleryMenus_01_Map"></td>
			</tr>
		</table>
		<map name="galleryMenus_01_Map">
		<area shape="rect" alt="" coords="0,0,86,34" href="#"
			onmouseover="toggleImages('Current', new Array('galleryMenus_01', 'images/galleryMenus_01-Archived_ov.gif'), '', new Array('galleryMenus_01', 'images/galleryMenus_01-Archived-05.gif')); return true;"
			onmouseout="toggleImages('Archived', new Array('galleryMenus_01', 'images/galleryMenus_01-Archived-05.gif'), 'Current', new Array('galleryMenus_01', 'images/galleryMenus_01-Current_-04.gif'), '', new Array('galleryMenus_01', 'images/galleryMenus_01.gif')); return true;"
			onmouseup="selected='Archived'; changeImages('galleryMenus_01', 'images/galleryMenus_01-Archived-05.gif'); return true;">
		<area shape="rect" alt="" coords="78,0,164,34" href="#"
			onmouseover="toggleImages('Archived', new Array('galleryMenus_01', 'images/galleryMenus_01-Current_ove.gif'), '', new Array('galleryMenus_01', 'images/galleryMenus_01-Current_-04.gif')); return true;"
			onmouseout="toggleImages('Archived', new Array('galleryMenus_01', 'images/galleryMenus_01-Archived-05.gif'), 'Current', new Array('galleryMenus_01', 'images/galleryMenus_01-Current_-04.gif'), '', new Array('galleryMenus_01', 'images/galleryMenus_01.gif')); return true;"
			onmouseup="selected='Current'; changeImages('galleryMenus_01', 'images/galleryMenus_01-Current_-04.gif'); return true;">
		</map>


What I'm trying to do is creating a rollover menu buttons or tabs that according to which menu button it was clicked, a table with data from the MySQL database will show up on that same page.

Any help is gratefuly.

ljCharlie
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Or herhaps anyone can show me how to use a hyper link that will send a value showing which button it was clicked.

ljCharlie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why not just have a link for them to click?

imagemaps are passe. ;)
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Yes, I thought of that...but I want to have menu tabs. I wonder if that is possible.

Thanks for your response.

ljCharlie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you don't need image maps to have menu tabs. You don't need image maps ever anymore.. (pretty much)
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

I have tried this:

<area shape="rect" alt="" coords="0,0,86,34" href=\"<?PHP echo $self?mnuArchived="Archived"\ ?>"

But it's not working. Maybe I'm missing something.

ljCharlie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that'd be quotes you're missing. :P
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Will you show me what quotes I'm missing?

Thanks!

ljCharlie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<area shape="rect" alt="" coords="0,0,86,34" href="<?PHP echo "{$_SERVER['SCRIPT_NAME']}?mnuArchived=Archived" ?>" />
similar to that.
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

It works; however, there is a slight problem. The menu button don't stay selected anymore. When clicked on the menu button, the page does refresh and I believed it also pass a line a variable too but the buton no longer stay on a selected state.

Any idea on how to fix this?

ljCharlie
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

And by the way, instead of href do you think it's possible to implement a onClick() with the same function....meaing refresh the page and also pass along a variable?

ljCharlie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

make the image used dynamic based on the current value of the variable(s) .. make sure to have processing for default (no variable) too.
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Sorry for asking a lot of questions but, what do you mean by making the miage use dynamic base? And how do I do that? Quick example is appreciated.

ljCharlie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<?php

$var = isset($_GET['mnuArchive']) ? $_GET['mnuArchive'] : '';

switch($var)
{
case 'Archived':
  $image = 'archived.jpg';
  break;

case 'Foo':
  $image = 'something_else.jpg';
  break;

default:
  $image = 'default.jpg';
  break;
}

echo '<img src="' . $image . '" usemap="#whatever" />';

?>
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

So by having a the image using a dynamic base that should solve the problem of the button not on selected state, right?

ljCharlie
Post Reply