Page 1 of 1

PHP and Javascript

Posted: Mon Apr 19, 2004 6:46 pm
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>";

Posted: Mon Apr 19, 2004 6:48 pm
by magicrobotmonkey
what's this silliness?

href ' ' =onClick

did you even read over your code?

Posted: Mon Apr 19, 2004 6:53 pm
by nikko50
Please explain???
SHaron

Posted: Mon Apr 19, 2004 7:05 pm
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

Posted: Mon Apr 19, 2004 7:05 pm
by magicrobotmonkey
I dont think that's standard javascript syntax - plus imho its neater to decalre a function

Posted: Mon Apr 19, 2004 7:07 pm
by feyd

Code: Select all

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

Code: Select all

<a href='#' onclick='window....
should take care of it

Posted: Mon Apr 19, 2004 7:11 pm
by magicrobotmonkey
heh beat me too it but done better! nice work

Posted: Mon Apr 19, 2004 7:14 pm
by nikko50
Thanks so much guys!
Hugs,
Sharon