For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > October 2004 > 'onmouseover' javascript in .php echo command, is proving troublesome?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author 'onmouseover' javascript in .php echo command, is proving troublesome?
Mark

2004-10-22, 8:55 pm

Hi,

Can anyone please tell me what is wrong with this code ?

I have a 2d Array defined in an included PHP file as follows :-

/Site #1
$sitename[0][0]="The Site Name";
$bannerlocation[0][0]="banners/468x60_2126.gif";
$bannerdescrition[0][0]="Visit my site!";
$sitelink[0][0]=http://www.mysite.com;


In my main PHP file, I have the following line

echo "<center><a href='".$sitelink[$bantype][$bancode]."'
onmouseover='status=\"Visit .$sitename[$bantype][$bancode]. \"'; return
true' onmouseout='status=\" \"; return true'
target='".$sitename[$bantype][$bancode]."'><img
src='".$bannerlocation[$bantype][$bancode]."' border='0'
alt='".$bannerdescription[$bantype][$bancode]."'></a></center><br>";


This displays the graphic accordingly, and the link also works. HOWEVER,
when placing the mouse over the banner, instead of saying "Visit The Site
Name", it says the href link on the status bar instead, as if the
'onmouseover' javascript never existed ?


Any help much appreciated.


Thanks, Mark


jrf[no]

2004-10-23, 3:55 am

Mark wrote:
> Hi,
>
> Can anyone please tell me what is wrong with this code ?
>
> I have a 2d Array defined in an included PHP file as follows :-
>
> /Site #1
> $sitename[0][0]="The Site Name";
> $bannerlocation[0][0]="banners/468x60_2126.gif";
> $bannerdescrition[0][0]="Visit my site!";
> $sitelink[0][0]=http://www.mysite.com;
>
>
> In my main PHP file, I have the following line
>
> echo "<center><a href='".$sitelink[$bantype][$bancode]."'
> onmouseover='status=\"Visit .$sitename[$bantype][$bancode]. \"'; return
> true' onmouseout='status=\" \"; return true'
> target='".$sitename[$bantype][$bancode]."'><img
> src='".$bannerlocation[$bantype][$bancode]."' border='0'
> alt='".$bannerdescription[$bantype][$bancode]."'></a></center><br>";
>
>
> This displays the graphic accordingly, and the link also works. HOWEVER,
> when placing the mouse over the banner, instead of saying "Visit The Site
> Name", it says the href link on the status bar instead, as if the
> 'onmouseover' javascript never existed ?
>
>
> Any help much appreciated.
>
>
> Thanks, Mark
>
>


You're missing some quotes ... Did you look at the resulting source ? It
would have showed you the problem

Try this:

echo '<center><a href="' . $sitelink[$bantype][$bancode]. '"
onmouseover="status='Visit ' . $sitename[$bantype][$bancode]. '';
return true;" onmouseout="status=' '; return true;" target="'
.. $sitename[$bantype][$bancode] . '"><img src="'
.. $bannerlocation[$bantype][$bancode] . '" border="0" alt="'
.. $bannerdescription[$bantype][$bancode] . '"></a></center><br>';
Duyet The Vo

2004-10-23, 3:55 am

I would not break the line at "return true". Also use onmouseover=" .... "

This works:

echo "<center><a href='".$sitelink[$bantype][$bancode]."'
onmouseover=\"status='Visit ".$sitename[$bantype][$bancode]." '; return
true\"
onmouseout='status=\" \"; return true'
target='".$sitename[$bantype][$bancode]."'><img
src='".$bannerlocation[$bantype][$bancode]."' border='0'
alt='".$bannerdescription[$bantype][$bancode]."'></a></center><br>";

HTH.

"Mark" <mark_news@horsemad.co.uk> wrote in message
news:9yfed.254$qj2.253@newsfe6-win.ntli.net...
> Hi,
>
> Can anyone please tell me what is wrong with this code ?
>
> I have a 2d Array defined in an included PHP file as follows :-
>
> /Site #1
> $sitename[0][0]="The Site Name";
> $bannerlocation[0][0]="banners/468x60_2126.gif";
> $bannerdescrition[0][0]="Visit my site!";
> $sitelink[0][0]=http://www.mysite.com;
>
>
> In my main PHP file, I have the following line
>
> echo "<center><a href='".$sitelink[$bantype][$bancode]."'
> onmouseover='status=\"Visit .$sitename[$bantype][$bancode]. \"'; return
> true' onmouseout='status=\" \"; return true'
> target='".$sitename[$bantype][$bancode]."'><img
> src='".$bannerlocation[$bantype][$bancode]."' border='0'
> alt='".$bannerdescription[$bantype][$bancode]."'></a></center><br>";
>
>
> This displays the graphic accordingly, and the link also works. HOWEVER,
> when placing the mouse over the banner, instead of saying "Visit The Site
> Name", it says the href link on the status bar instead, as if the
> 'onmouseover' javascript never existed ?
>
>
> Any help much appreciated.
>
>
> Thanks, Mark
>
>



Mark

2004-10-24, 8:55 am

Excellent - Thankyou both for your help.


Thanks, Mark


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com