Hi All,

I am back with more tips and tricks of Javascript, to make it “fun with Javascript” . Contrary to common layman notion that javascript is not user friendly or not very reliable, it is very reliable and user friendly. Sample this even google and Yahoo use them in there application, this shows the reliabilty and flexibilty Javascript offer.

Today I shall discuss “how can we call Javascript function from PHP code without any click event happening on our page”

Here is sample code:

Write you Javascript function in HEAD

/HEAD/
/SCRIPT LANGUAGE=”javascript”/
function ProcA () {
alert (“message”);
}
//SCRIPT/
//Head/

Calling this function from PHP code -for instance based on a decision.

if ($decision==’true’) {
echo “/SCRIPT LANGUAGE=”javascript”/”;
echo “FunctionA;n”;
echo “//SCRIPT/
}
?>

P.S- repleace / with < or > whereever applicable.

Code End here///////////////////

That simple noooooooo:)

If you have any question/queries. Contact us at www.varshyltech.com

Share