Re: Why Doesn't My Javascript Work With PHP?
| From: | David Newcomb | Date: | Wed, 23 Aug 2000 09:25:37 +0000 |
| Subject: | Re: Why Doesn't My Javascript Work With PHP? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13118@lists.php.net to get a copy of this message | ||
It looks like the Javascript function, horseWindow() will
be redeclared more than once. Can you be a bit more
specific about the "it dose not work". Can you capture the output
of the php script and mail it to the list?
Have you changed version/OS/db since the old server?
----- Original Message -----
From: Ben Ocean <beno@cnw.com>
To: <jasonc@webpipe.net>
Cc: <php-general@lists.php.net>
Sent: Wednesday, August 23, 2000 12:22 AM
Subject: Re: [PHP] Why Doesn't My Javascript Work With PHP?
> At 01:55 PM 8/22/2000 -0700, you wrote:
> >You should remember that PHP couldn't care less about JavaScript.
JavaScript
> >is executed client side. Php is long gone by the time JavaScript goes
into
> >action. Post your code and maybe we can figure it out. Also, view
source on
> >the page that's messed up and look at the JavaScript.
>
> Here's a sample of the code. Like I said, it worked fine on the old
server.
> The problem is outlined below the code:
>
> elseif ($genderz !=9) {
> echo "<span class=\"resultsHeader\"><h1>Here's Your
> Horses!</h1></span>";
> echo "<span class=\"lead\">";
> echo "Click on any horse. It will open a new window. To see
> another horse from this selection, simply close down that window and
you'll
> be right back here!</span>";
> echo "<span class=\"results\">";
> $result = mysql_query("SELECT id, gender, color, name, birth,
> price, performance_one, performance_more, height, description FROM horse
> ORDER BY price");
> $total_rows = mysql_numrows($result); $counter = 0; $countertwo =
0;
> while($counter < $total_rows):
> $id = mysql_result($result,$counter,"id");
> $genderee = mysql_result($result,$counter,"gender");
> $namee = mysql_result($result,$counter,"name");
> $coloree = mysql_result($result,$counter,"color");
> $pricee = mysql_result($result,$counter,"price");
> $birthee = mysql_result($result,$counter,"birth");
> $performance_onee =
> mysql_result($result,$counter,"performance_one");
> $performance_moree =
> mysql_result($result,$counter,"performance_more");
> $heightee = mysql_result($result,$counter,"height");
> $descriptionee =
mysql_result($result,$counter,"description");
> if ($genderee == $genderz) {
> ?>
> <a href="#a" onClick="horseWindow()">
> <script language="Javascript1.2">
> function horseWindow() {
> newWindow = window.open("Your_Horse.php3?name=<? echo
> $namee; ?>&color=<? echo $coloree; ?>&gender=<? echo $genderee;
> ?>&price=<? echo
> $pricee; ?>&birth=<? echo $birthee; ?>&performance_one=<? echo
> $performance_onee; ?>&performance_more=<? echo
> $performance_moree; ?>&height=<?
> echo $heightee; ?>&description=<? echo $descriptionee;
>
?>","","toolbar=1,menubar=0,width=800,height=600,scrollbars=1,status=0,locat
ion=0,directories=0,left=0,top=0");
> }
>
>
> </script>
> <?
> echo mysql_result($result,$counter,"name");
> echo "</a><br>";
> $countertwo = $countertwo + 1;
> }
> $counter = $counter + 1;
> endwhile;
> echo "</span>";
> if ($countertwo == 0) {
> echo "<span class=\"sorry\">I'm sorry, but
> there
> are no horses that fit your criteria. click the "Back" button on
> this browser window and try another search.</span>";
> }
> }
>
>
> > I have a Javascript that worked perfectly well on another server,
*then* I
> > > built my own server. I have other PHP/MySQL scripts that work
perfectly
> > > well on my new server. But for some reason, a certain Javascript,
nested
> > > within a *while* statement acts crazy.
> > >
> > > What I want to occur is to generate information about specific horses
> > > selected by search criteria. The script correctly prints to screen the
> > name
> > > of the horse. This is surrounded by an anchor tag. I can pass the
correct
> > > information about the specific horse through the tag to the new page
> > > *without* Javascript, but when I use the Javascript, what happens is
the
> > > information that is supposed to be passed with the anchor for each
> > horse is
> > > replaced with new information each time the *while* statement is
executed.
> > > The result is that all the *names* of the horses print to screen
> > correctly,
> > > but when you click on one, it pulls up the information for the last
horse
> > > on the list!
> > >
> > > To make matters worse, the page with the list of horses names is
> > > intentionally small, but the page I generate for the specific horses
must
> > > be full-sized. I cannot do this with a *target="_blank"* line of code:
I
> > > have to use Javascript.
> > >
> > > What am I doing wrong?
> > > TIA,
> > > BenO