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
taha
Forum Newbie
Posts: 17 Joined: Tue Nov 22, 2005 2:40 pm
Post
by taha » Wed Nov 23, 2005 4:06 pm
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... » Wed Nov 23, 2005 4:12 pm
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 » Wed Nov 23, 2005 4:31 pm
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 » Wed Nov 23, 2005 6:53 pm
Code: Select all
<?php
echo ('<script language="javascript">alert(\'hello world\');</script>');
?>
PHP can generate javascript he's saying