Wednesday, March 2, 2011

php javascript confirm alert box


There are many times when you are working with php, drawing content from mysql and you need a function to draw on the Javascript confirm (alert with Yes and No option buttons) script. Learn how to pass in a parameter to Javascript and open another php file to complete the confirm action.

First write the Javascript function that passes a parameter
function go_there(name)
{
var p=name;
 var where_to= confirm("This action sends the data for this profile to the analysis center nd you will not be able to change the data later.\r\nAre you sure you want to make your data Finalized READ ONLY? ");
 if (where_to== true)
 {
   window.location="index.php?page=finalize&profile="+p;
 }

}

Then on you php call the function: I have removed all quotes, therefore fix the code before use.

echo go_there(. $data[profile].); href=#>finalize;



enjoy!

No comments:

Post a Comment