Ask a Question related to PHP Development, Design and Development.
-
Steve #1
Can Javascript be called from PHP?
Can Javascript be called from PHP? I was just trying to implement a little
print button that appeared if a certain condition was met like this:
<?
if ($reject=="0") {echo "<a href="javascript:print()""><img
src="images/print_button.gif" width="82" height="22" border="0"></a></p>;};
?>
but this fails spectacularly! I'm sure there is a good reason why - if only
I could poinpoint what it is!
Anybody care to enlighten me?
THANKS!
Steve
Steve Guest
-
#39868 [NEW]: Destructor is called allthought constructor is never called
From: jb at ez dot no Operating system: Kubuntu 6.10 PHP version: 5.2.0 PHP Bug Type: *General Issues Bug description: ... -
#39678 [Opn->Bgs]: __set and __get not called where a class attribute is called statically
ID: 39678 Updated by: tony2001@php.net Reported By: denis at edistar dot com -Status: Open +Status: ... -
#39678 [NEW]: __set and __get not called where a class attribute is called statically
From: denis at edistar dot com Operating system: Linux PHP version: 5.2.0 PHP Bug Type: Scripting Engine problem Bug... -
Include javascript in a javascript file
Hello, Is there a way to include a javascript file from WITHIN a javascript file? Something similar as in the "#include" directive in C++? ... -
need javascript staff (anyone who knows javascript peroid) (READ)
hey its me ultimategamerx and im back in some clothes lol i need some people who know java script i need help please reply if ya know some -
Matt Foster #2
Re: Can Javascript be called from PHP?
You can't put quotes in quotes!
Try
<?
if ($reject=="0") {
echo "<a href=javascript:print()><img src=images/print_button.gif width=82
height=22 border=0></a></p>";
}
?>
"Steve" <luckylucky200@hotmail.com> wrote in message
news:4d2307447503850bd336e6e688825024@news.teranew s.com...border="0"></a></p>;};> Can Javascript be called from PHP? I was just trying to implement a little
> print button that appeared if a certain condition was met like this:
>
> <?
>
> if ($reject=="0") {echo "<a href="javascript:print()""><img
> src="images/print_button.gif" width="82" height="22"only>
> ?>
>
> but this fails spectacularly! I'm sure there is a good reason why - if> I could poinpoint what it is!
>
> Anybody care to enlighten me?
>
> THANKS!
>
> Steve
>
>
Matt Foster Guest
-
Steve #3
Re: Can Javascript be called from PHP?
"Ian.H" <ian@WINDOZEdigiserv.net> wrote in message
news:pan.2004.04.05.14.51.27.844000@bubbleboy.digi serv.net...little> [ Rearranged into correct Usenet, chronological order ]
>
>> > "Steve" <luckylucky200@hotmail.com> wrote in message
> > news:4d2307447503850bd336e6e688825024@news.teranew s.com...> >> Can Javascript be called from PHP? I was just trying to implement awidth=82>> > border="0"></a></p>;};> >> print button that appeared if a certain condition was met like this:
> >>
> >> <?
> >>
> >> if ($reject=="0") {echo "<a href="javascript:print()""><img
> >> src="images/print_button.gif" width="82" height="22"> > only> >>
> >> ?>
> >>
> >> but this fails spectacularly! I'm sure there is a good reason why - if> >> I could poinpoint what it is!
> >>
> >> Anybody care to enlighten me?
> >>
> >> THANKS!
>
> On Mon, 05 Apr 2004 14:26:04 +0000, Matt Foster wrote:
>> > You can't put quotes in quotes!
> >
> > Try
> >
> > <?
> >
> > if ($reject=="0") {
> > echo "<a href=javascript:print()><img src=images/print_button.gifThanks Again - you guys saved my life today! - Those damn single and double>> > height=22 border=0></a></p>";
> > }
> >
> >
> > ?>
>
> Don't use this! HTML attribute values should be quoted themselves also.
>
> if ($reject == 0) {
> echo '<a href="javascript:print();"><img src="images/print_button.gif"
> width="8px" height="22px" border="0"></a>';
> }
>
>
> Notice here also that I deliberately left the quotes out arout the 0 in
> the if() call. Unless you _really_ mean a string containing a zero char,
> then the quotes aren't required. Both work... but one is _preferred_ over
> the other =)
>
> The other thing slightly differnt.. is I've used ' ' (single quotes) for
> the echo call. As you have no $vars to parse within the string... there's
> no need to use double-quotes. This is an aside.. an optimisation..
> although if your application ever relies on this for noticable
> optimisation, you have severe issues elsewhere.
>
> One last thing I'm just throwing in FWIW and not PHP related... your
> 'javascript:print()' call.. this should really use a return call:
>
>
> return print_page();
>
>
> or similar and have your print definitions within that function. This
> should then help in situations where Javascript isn't available to the
> browser:
>
>
> <a href="/print.php" onlick="return print_page();" ...>Print</a>
>
>
> or something similar.
>
> Hope this is read as constructive rather than criticism =)
>
>
>
> Regards,
>
> Ian
>
> --
> Ian.H
> digiServ Network
> London, UK
> [url]http://digiserv.net/[/url]
>
quotes - I'll get em one day!
Steve
Steve Guest
-
Smifffy #4
Re: Can Javascript be called from PHP?
use this
[CODE]
<?php
if ($reject == 0)
{
echo "<a href=\"javascript:print()\"\"><img
src=\"images/print_button.gif\" width=\"82\" height=\"22\"
border=\"0\"></a></p>";
}
?>
Steve wrote:
> Can Javascript be called from PHP? I was just trying to implement a little
> print button that appeared if a certain condition was met like this:
>
> <?
>
> if ($reject=="0") {echo "<a href="javascript:print()""><img
> src="images/print_button.gif" width="82" height="22" border="0"></a></p>;};
>
> ?>
>
> but this fails spectacularly! I'm sure there is a good reason why - if only
> I could poinpoint what it is!
>
> Anybody care to enlighten me?
>
> THANKS!
>
> Steve
>
>Smifffy Guest



Reply With Quote

