You are here: Re: Help !!! a bit of javascript mixed with PHP « PHP Language « IT news, forums, messages
Re: Help !!! a bit of javascript mixed with PHP

Posted by Kimmo Laine on 06/29/05 08:41

"Hilarion" <m0rt_nospam_@nospam_bez_spamu_itepe_poczta.onet.pl> wrote in
message news:d9se53$msr$1@news.onet.pl...
> Domestos wrote:
>> Cruddy code examples on the net... ported into my program and don't
>> work...
>> any idea's?
>>
>> echo '<a href="javascript: void(0)"
>> onClick="window.open("club_info.php?clubcode="'.$code.'","mypage","width=300
>> ,height=300,toolbar=0,resizable=0,scrollable=1");"><img src="'.$badge.'"
>> width="50" height="50" border="0" ALT="'.$name.'">'</a>';
>
> It almost works (just remove the "'" sign before "</a>").
> The problem is that this PHP code generates invalid HTML.
> The solution is:
> 1. Look at the HTML code it generates.
> 2. Fix the HTML code.
> 3. Copy and paste the correct HTML code into your PHP code.
>

Yes, the php will work correctly once the extra ' is removed. Still the
javascript is incorrect. To fix the javascript, OP should convert some
double qoutes that are broken to single qoutes and adjust the mis-placed
comma. Here's what the code generates:

<a href="javascript: void(0)"
onClick="window.open("club_info.php?clubcode="",mypage,width=300
,height=300,toolbar=0,resizable=0,scrollable=1");"><img src=""
width="50" height="50" border="0" ALT=""></a>

The thing is, double qoutes inside double quotes is sexual harrasment, and
that makes me a saaaaad panda. What it _should_ generate:

<a href="javascript: void(0)"
onClick="window.open('club_info.php?clubcode=','mypage,width=300
,height=300,toolbar=0,resizable=0,scrollable=1');"><img src=""
width="50" height="50" border="0" ALT=""></a>

Long story short: here's a code that should work (I tested and it did work)

echo "<a href='javascript: void(0)'
onClick=\"window.open('club_info.php?clubcode=$code', 'mypage',
'width=300, height=300,toolbar=0,resizable=0,scrollable=1');\">
<img src='$badge' width='50' height='50' border='0' ALT='$name'></a>";

--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

eternal.erectionN0@5P4Mgmail.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация