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

This is a discussion on 'onmouseover' javascript in .php echo command, is proving troublesome? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, Can anyone please tell me what is wrong with this code ? I have a 2d Array defined in an ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-22-2004
Mark
 
Posts: n/a
Default 'onmouseover' javascript in .php echo command, is proving troublesome?

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


Reply With Quote
  #2 (permalink)  
Old 10-23-2004
jrf[no]
 
Posts: n/a
Default Re: 'onmouseover' javascript in .php echo command, is proving troublesome?

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>';
Reply With Quote
  #3 (permalink)  
Old 10-23-2004
Duyet The Vo
 
Posts: n/a
Default Re: 'onmouseover' javascript in .php echo command, is proving troublesome?

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
>
>



Reply With Quote
  #4 (permalink)  
Old 10-24-2004
Mark
 
Posts: n/a
Default Re: 'onmouseover' javascript in .php echo command, is proving troublesome?

Excellent - Thankyou both for your help.


Thanks, Mark


Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:56 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0