Friday, July 2, 2010

Passing Values from PHP to Javascript

Hi Developers,
We can able to send values from php to javascript using php coding without submit the form using submit button.
I think most of you are having knowledge to send values from php to javascript but i am posting for new buddies & myself

1)Create a New PHP page(sample.php) and Copy & Paste it.

echo "Hello ";
echo "
";
echo "Hello ";
echo "
";
echo "Hello ";
And ADD SCRIPT TAGS
function test(url) {
var chk = confirm ("Can i proceed?");
if(chk){
location.href=url;
}else{
alert('oooppppppppps');
}
}
Close SCRIPT TAGS.


2)Create a other New PHP page(test.php) and Copy & Paste it.

echo $_GET['id'];


Execute the code in the browser that php values are passed to javascript :)

Example Application:
Basic functionality for any appication in website i.e Delete a record in the database.


Gud Luck :)