start a function without pressing button after PHP

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

start a function without pressing button after PHP

Post by Goofan »

Hi I wonder if there is some kind of way to start a function after a button have been pressed and the php has done some stuffs then it would
automatically start up? Not when you press a button but on "normal" command... I guess its a basic question but I need the help for it so. =)



Code exampel:

Code: Select all

 
if(isset($_POST['dogs']))
{
  If ($money > $Spend){
-->   run javascript function  <--
  }
 
}
 
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: start a function without pressing button after PHP

Post by AbraCadaver »

You'll have to be more specific, but it appears as easy as this:

Code: Select all

if(isset($_POST['dogs']))
{
 if($money > $Spend){
     echo '
      <script type="text/javascript">
      yourJSfunc();
      </script>';
  }
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: start a function without pressing button after PHP

Post by Goofan »

yea well that was what i meant. thats why i had the exampel code... but is it really as easy as calling the function likely that? no special commands or so? "thought js would make that bit harder"
Post Reply