This topic is locked
[SOLVED]

 Javascript OnLoad Event

5/6/2011 10:24:36 AM
PHPRunner General questions
G
Goshen author

I am trying to show a Popup window with a message based on a variable set in before display.
Here is what I am doing process wise.
i have a forum for the user to search for a servername from the interfaces table.

They are presented with records under the search return. Then they select the view record (interfaces table).
In the beforedisplay I do an additional sqlquery to get the status of the network device for automated provisioining and it the value of the provisioning field is set to on I will allow them to alter the configuration. If it is set to zero or null then I set a $action="0" in the beforedisplay.
Then in the Javascript onLoad event

I have this:
// Before display //
$params["action"]=""; // Establish $params

global $conn; // Self explanatory of you know PHPRUNNER

$host = $values["device"]; // This is the network device ( basically a cisco or other vendor switch)( my automation process is an external set of PHP that runs from an Include )

$strSQLGet = "select penabled from deviceinfo where dname = '$host' "; // this determines if the device is allow to be provisioned via the automation system

$SqlResults=db_query($strSQLGet,$conn);

$result1=db_fetch_array($SqlResults);

$rs=$result1["penabled"]; // This will return 1, 0 or NULL. (DB default field is set to NULL)
$xt->assign('prev_button',false); // This hides the button

$xt->assign('back_button',false); // This hides the button

$xt->assign('next_button',false); // This hides the button
if($rs === "1") { // device is enabled for provisioning if the $rs returns a value of "1"

$xt->assign("RMenu_button",true); // I want to make sure this button is on.

$xt->assign("execdepro_button",true); // The button to execute a deprovision on the physical switch port on the device is enabled if $rs =="1"

//echo "result is ONE Link set to true"; // my test code Ignore

} else {

$xt->assign("RMenu_button",true); // Keep the Return to Main menu button on

$xt->assign("execdepro_button",false); // Disable the Deprovisioning button if the returned value of $rs == 0 or NULL

echo " DeProvisioning for this device is not authorized at this time "; // My validation echo only for coding.. This does show my if process works correctly.

$params["txt"]=" DeProvisioning for this device is not authorized at this time "; // Set the message text to be displayed in the PopUp window //

$result["txt"]= $params["txt"]; // Seems redundant to me but I am going by the example code from other buttons that display message.

$params["action"]="1"; // Added this because I can't seem to pass a $value="x" over to the javaprocess. I am proabably missing what happens here...

$result["action"]= $params["action"]; // Put the value of $params["action"] into the $result["action"]
//javascript OnLoad Event

var status = result["action"];
if (status = 0) {

var message = result["action"];

alert(message);

} else {

}
// Additionally I started by setting $action="1" in the on display section and

in On javascript OnLoad event
if (action = = 1) {

blah

blah
That did not work because action in the javascript always returned false or 0.
Can I pass a $value that I create and is not part of the forum into the Javascript OnLoad Event process? If so I can't determine that from the documentation.