DarkPrince2005 Posted April 20, 2008 Share Posted April 20, 2008 can anyone please tell me why my javascript isn't working within my php code <?php header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', FALSE); header('Pragma: no-cache'); ini_set('display_errors','On'); error_reporting(E_ALL); ini_set('session.cache_limiter',''); session_start(); if(!isset($_SESSION['isLoggedIn']) || (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] != true)) { die('<html> <head> <title></title> <style> .scrollable { width: 100%; height: 500px; overflow: auto; background-repeat:no-repeat; } td{background-repeat: no-repeat; } </style> </head> <body topmargin="0" bottommargin="0" rightmargin="0" leftmargin="0" bgcolor="#FFFFFF"> <center><table cellspacing="0" cellpadding="0" border="0" height="100%"> <tr> <td width="1024" height="75" background="top.jpg" colspan="2"> </td> </tr> <tr> <td width="1024" height="13" background="top1.jpg" colspan="2" align="right"><font size="2"><a href="">Login</a></font> </td> </tr> <tr> <td width="1024" height="13" background="top2.jpg" colspan="2"> </td> </tr> <tr> <td width="168" background="nav.jpg" valign="top"><br><a href="view.php"><img src="mainview.gif" align="center" width="150" border="0"></a> <br><a href="add.php"><img src="mainadd.gif" align="center" width="150" border="0"></a> <br><a href="edit.php"><img src="mainedit.gif" align="center" width="150" border="0"></a> <br><img src="maindelete.gif" align="center" width="150"> <br><img src="mainsearch.gif" align="center" width="150"> <br><img src="mainreport.gif" align="center" width="150"></td> <td width="856" background="main.jpg" align="center" valign="top"><br>You must be <a href="login.php">logged in</a> in order to view this page! </td> </tr> </table> </center> </form></div> </td> </tr> </table>'); }else{$SESSION['isLoggedIn']='true';}; echo "<html> <head> <title></title> <style> .scrollable { width: 100%; height: 500px; overflow: auto; background-repeat:no-repeat; } td{background-repeat: no-repeat; } </style> <script language=\"JavaScript\"> function codename() { if(document.form1.clientid_1.checked) { document.form1.clientid.disabled=false; document.form1.clientid.focus(); } else { document.form1.clientid.disabled=true; } if(document.form1.surname_1.checked) { document.form1.surname.disabled=false; } else { document.form1.surname.disabled=true; document.form1.surname.focus(); }} </script> </head> <body topmargin='0' bottommargin='0' rightmargin='0' leftmargin='0' bgcolor='#FFFFFF'> <center><table cellspacing='0' cellpadding='0' border='0' height='100%'> <tr> <td width='1024' height='75' background='top.jpg' colspan='2'> </td> </tr> <tr> <td width='1024' height='20' background='top1.jpg' colspan='2' align='right' valign='center'><font size='3'>"; echo "Currently logged in as <b>$_SESSION[usernam]</b> | <a href='logout.php'><font color='#343635'><b>Logout<b></font></a> </td> </tr> <tr> <td width='1024' height='13' background='top2.jpg' colspan='2'> </td> </tr> <tr><td width='168' background='nav.jpg' valign='top'><br><a href='view.php'><img src='mainview.gif' align='center' width='150' border='0'></a> <br><a href='add.php'><img src='mainadd.gif' align='center' width='150' border='0'></a> <br><a href='edit.php'><img src='mainedit.gif' align='center' width='150' border='0'></a> <br><img src='maindelete.gif' align='center' width='150'> <br><img src='mainsearch.gif' align='center' width='150'> <br><img src='mainreport.gif' align='center' width='150'></td> <td width='856' background='main.jpg' align='center' valign='top'><br><div class='scrollable'> <form name='form1' method='post' action='2.php'> <table> <tr> <td colspan='9'><input type='checkbox' name='clientid_1'>Client ID</td> </tr> <tr> <td> </td> <td colspan='8'><input type='text' name='clientid' size='10'></td> </tr> <tr> <td colspan='9'><input type='checkbox' name='surname_1'>Surname</td> </tr> <tr> <td> </td> <td colspan='8'><input type='text' name='surname' size='40'></td> </tr> <tr> <td colspan='9'> </td> </tr> <tr> <td colspan='9' align='center'><input type='image' src='save.gif' value='Submit' alt='Submit'></td> </tr> <tr> <td colspan='9'> </td> </tr> </table></form></div> </td> </tr> </table>"; ?> Link to comment https://forums.phpfreaks.com/topic/102041-echoing-javascript-problem/ Share on other sites More sharing options...
dptr1988 Posted April 20, 2008 Share Posted April 20, 2008 JavaScript doesn't work 'within' PHP code. JavaScript works in the webbrowser on the clients computer. If you need to debug JavaScript, look at the JavaScript code that the browser sees ( View Source ) rather then the JavaScript code that is in your PHP source files and ask for help in the JavaScript forum http://www.phpfreaks.com/forums/index.php/board,6.0.html. Link to comment https://forums.phpfreaks.com/topic/102041-echoing-javascript-problem/#findComment-522214 Share on other sites More sharing options...
DarkPrince2005 Posted April 20, 2008 Author Share Posted April 20, 2008 Ok let me state my question this way: How do you echo Javascript in php? Link to comment https://forums.phpfreaks.com/topic/102041-echoing-javascript-problem/#findComment-522215 Share on other sites More sharing options...
DarkPrince2005 Posted April 20, 2008 Author Share Posted April 20, 2008 Nevermind I found the problem, it was code that i forgot to put in Link to comment https://forums.phpfreaks.com/topic/102041-echoing-javascript-problem/#findComment-522224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.