Help - Search - Member List - Calendar
Full Version: Help !!! a bit of javascript mixed with PHP
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
Domestos
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>';

Peter
QUOTE
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>';

psychic ability is alluding me at the moment so may be best if you say what
is happening instead of just saying it is not working.

1 thing that is wrong is the fact that you have an extra ' before </a>

Hilarion
Domestos wrote:
QUOTE
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.

If you are unable to do the 1 and 2, then try learning HTML before trying
to use PHP.

Where did you get the code from anyway?


Hilarion

Tony
Hilarion wrote:
QUOTE
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.

If you are unable to do the 1 and 2, then try learning HTML before
trying to use PHP.

See the guy's other post and you'll understand better...

--
Tony Garcia
Web Right! Development

Domestos
QUOTE

See the guy's other post and you'll understand better...

--
Tony Garcia
Web Right! Development



Sorry Tony - have I upset you in some way??

Kimmo Laine
"Hilarion" <m0rt_nospam_@nospam_bez_spamu_itepe_poczta.onet.pl> wrote in
message news:d9se53$msr$[Email Removed]...
QUOTE
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

[Email Removed]


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.