Page 1 of 1

PHP code needs to be converted to Javascript

Posted: Wed Nov 23, 2005 4:06 pm
by taha
I have a function that is written in javascript, see code below:

Code: Select all

function checkNewConfig()
  {     
     if ($_SESSION['genericNewConfig'])
     { 
        echo '<INPUT TYPE=submit VALUE="Save"    NAME="generic_savebutton"   ONCLICK="verifySave()" />'; 
        echo '<INPUT TYPE=reset  VALUE="Cancel"  NAME="generic_cancelbutton" ONCLICK="verifyCancel()" />';
     }
     else 
     {
        echo '<INPUT TYPE=button VALUE="Save"   NAME="generic_savebutton"   DISABLED="disabled" />';  
        echo '<INPUT TYPE=button VALUE="Cancel" NAME="generic_cancelbutton" DISABLED="disabled" />';
     }
  }
The problem is this function is a javascript method, and the contents inside are in php...how can i convert the php stuff to javascript???
Please help?

Posted: Wed Nov 23, 2005 4:12 pm
by Grim...
PHP can output JScript just like it can output HTML - just print / echo it.

Posted: Wed Nov 23, 2005 4:31 pm
by taha
Excuse my ignorance, i'm not sure what you mean??

Posted: Wed Nov 23, 2005 6:53 pm
by josh

Code: Select all

<?php
echo ('<script language="javascript">alert(\'hello world\');</script>');
?>
PHP can generate javascript he's saying