Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2005, 02:52 AM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default javascript with php

hi all,

is there a way to incorporate javascript with php.
i was trying to do a onclick button to close form but it does not seems to work.

print "<TR><TD align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Add?\">
<input type=\"button\" value=\"Nope !\" onclick='javascript:Close()'></TD></TR>\n";
print "<TR><TD><IMG height=\"10\" src=\"Images/px1.gif\" width=\"1\" border=\"0\"></TD></TR>\n";

i tried closing off the php and do a normal button type but it nvr work either

print "<TR><TD align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Add?\">\n";
?>
<input type="button" value="Nope !" onclick='javascript:Close()'>
<?php
print "</TD></TR>\n";

someone help pls.
thx
 
Old January 30th, 2005, 02:42 AM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You don't have to put your javascript in your php code at all for what you are doing. Just make sure your PHP is code is inside


<?PHP

//YOUR PHP CODE HERE


?>


//Javascript code here: like:
<input type="button" value"nope" onclick="javascipt:close()">



<?PHP

//More php code here


?>

Also echo is generally preferred and faster than the print function in php. For more info visit here: http://dynacker.dotgeek.org/printvsecho/


----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old January 30th, 2005, 01:57 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i tried but it nvr work...

echo "<TR><TD align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Add?\">\n";
echo "<input type=\"button\" value=\"Nope !\" onclick=\"javascript:close()\">";
echo "</TD></TR>\n";
 
Old January 30th, 2005, 10:17 PM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i was trying to say don't do echo at all.
Just put your javascript as you would normally outside php tags.

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old January 31st, 2005, 01:46 AM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i tried it. it can't work.
i close off the php tag and did a normal input button
My first post.

i tried closing off the php and do a normal button type but it nvr work either

print "<TR><TD align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Add?\">\n";
[u]?></u>

<input type="button" value="Nope !" onclick='javascript:Close()'>

[u]<?php</u>
print "</TD></TR>\n";
 
Old January 31st, 2005, 09:31 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Try

<input type="button" value="Nope !" onclick='Close()'>

-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old February 1st, 2005, 04:29 AM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi snib,

thanks for the help. but it nvr work.

i suppose ur code needs to do a function call???
<input type="button" value="Nope !" onclick='Close()'>

anyway, i tried but it nvr work...
anymore ideas?
 
Old February 1st, 2005, 06:16 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Have you declared the function Close()?

-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old February 1st, 2005, 10:59 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes i did. it just ain't closing the popup window.
nuthing seems to be happening...

do u want me to paste the code?
But its quite long.





Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and Javascript davidhayter Beginning PHP 5 May 6th, 2005 05:33 AM
How to use javascript with php? raichand_ray PHP How-To 2 November 12th, 2004 06:41 AM
javascript and php? Ashleek007 Beginning PHP 21 September 23rd, 2004 01:40 PM
PHP with Javascript Droobles Pro PHP 1 February 17th, 2004 03:08 PM
JavaScript and php Bandy PHP How-To 2 February 10th, 2004 04:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.