PHP and Javascript

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nikko50
Forum Commoner
Posts: 43
Joined: Thu Apr 08, 2004 6:28 am

PHP and Javascript

Post by nikko50 »

Hello. I'm trying to mix some javascript with my php. The below statement contains a line of Javascript that is not opening the PopUp window. Any suggestions on how to recode. Most likely it's a problem with the quotes and the semicolons. Please help.
Sharon

print "<tr>
<td width=9%>$line[date]</td>
<td width=20%>$line[recipient]</td>
<td width=30%>$getline[equipment]</td>
<td width=5%>$line[quantity]</td>
<td width=5%>$line[status]</td>

<font color=#0033CC><td width=4%><a href= updateloan.php?rowid=$line[id]><font color='#0000FF'>Edit</font> </a></td></font>
<td width=5%><a href ' ' =onClick= 'window.open('viewloan.php?rowid=$line[id]', 'View Loan',
'width=370,height=240,status=1'); return false;'><font color='#0000FF'>View</font> </a></td>
</tr>
</table>";
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

what's this silliness?

href ' ' =onClick

did you even read over your code?
nikko50
Forum Commoner
Posts: 43
Joined: Thu Apr 08, 2004 6:28 am

Post by nikko50 »

Please explain???
SHaron
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

<?php
print "<tr> 
<td width=9%>$line[date]</td> 
<td width=20%>$line[recipient]</td> 
<td width=30%>$getline[equipment]</td> 
<td width=5%>$line[quantity]</td> 
<td width=5%>$line[status]</td> 

<font color=#0033CC><td width=4%><a href= updateloan.php?rowid=$line[id]><font color='#0000FF'>Edit</font> </a></td></font> 
<td width=5%><a href ' ' =onClick= 'window.open('viewloan.php?rowid=$line[id]', 'View Loan', 
'width=370,height=240,status=1'); return false;'><font color='#0000FF'>View</font> </a></td> 
</tr> 
</table>";
?>
The line for your hyperlink doesn't mean anything.
<a href=' ' =onClick ='window.open('viewloan.php?........

Use something like

Code: Select all

&lt;a href='JavaScript:window.open('viewloan.php?rowid=$line&#1111;id]', 'View Loan', 
'width=370,height=240,status=1'); return false;'&gt;
You can't just point it to nothing but shove a load of javascript in the tags. Not a problem with semicolon etc, it's your javascript.

If you want to open a window in a particular size with javascript I'd do it like this anyway.

Code: Select all

/*Put this in your body and make sure you're between html tags*/
&lt;script&gt;
function openWindow() &#123;
var YourURL="urlcreate.php?name=&lt;?php echo $_GET&#1111;'n']; ?&gt;&amp;filenum=&lt;?php echo $_GET&#1111;'wap']; ?&gt;"
winpops=window.open(YourURL,"","width=350,height=130,scrollbars=0,")
&#125;
&lt;/script&gt;
and for your link simply write <a href="javascript:openWindow()">Link Here</a>

You can change the line that says var YourURL=....
to point to what ever url you wish.

Hope this helps
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

I dont think that's standard javascript syntax - plus imho its neater to decalre a function
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<a href ' ' =onClick= 'window....
to

Code: Select all

<a href='#' onclick='window....
should take care of it
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

heh beat me too it but done better! nice work
nikko50
Forum Commoner
Posts: 43
Joined: Thu Apr 08, 2004 6:28 am

Post by nikko50 »

Thanks so much guys!
Hugs,
Sharon
Post Reply