PHP code needs to be converted to Javascript

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
taha
Forum Newbie
Posts: 17
Joined: Tue Nov 22, 2005 2:40 pm

PHP code needs to be converted to Javascript

Post 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?
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

PHP can output JScript just like it can output HTML - just print / echo it.
taha
Forum Newbie
Posts: 17
Joined: Tue Nov 22, 2005 2:40 pm

Post by taha »

Excuse my ignorance, i'm not sure what you mean??
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Code: Select all

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