Helpful Information
 
 
Category: PHP Development
can i use JavaScrip and PhP on the same page ???

HI,
i want to use PhP and JavaScript (for event) on the same page but it doesn't work !
when i put the PhP's code before body tag the PhP code works but not the JavaScript Event code (onunload or onload)
and if i put body tag with javascript in then the PhP'code,The JavaScript works, the PhP generate well the page but it does'nt work bye example i do frames with my PhP code the code in source is right but i have'nt got not frame on my page !!!!

Hi Bixy,

it seems that you don't understand certain things right.

See it like this: PHP3 only GENERATES files. Whatever is in the file (HTML/JavaScript/or whatever) doesn't matter! If a JavaScript-script doesn't work, that hasn't got anything to do with the fact that it was created by a PHP3 script!

BTW: if you need help with JavaScript, ask it!

Bye

Marc aka Foddex

------------------
++++++++++++++++++++++++++++++++++++++++
ceterum censeo linguam c++ esse delendam

look my code:
<SCRIPT LANGUAGE="JavaScript">
/* (say only salut)*/
function cleanup()
{
alert('salut');
}
/* end of script */
</SCRIPT>
<TITLE> PhPForum </TITLE>
<META NAME="Author" CONTENT="BiXy">
<META NAME="Keywords" CONTENT="Forum">
<META NAME="Description" CONTENT="Forum Fait en PhP">
<HTML>
<?
require('config.inc');
if($txtnom=="")
{
//if no name enter echo "The name is no goodn";
echo "$retournomn";
}
else
{
//Select the index
$sqlstr="SELECT ind FROM listnom WHERE nom='$txtnom'";
mysql_connect($serverhost,$user,$pass);
$result=mysql_db_query($database,$sqlstr);
$nbr=mysql_num_rows($result);
mysql_close;
if ($nbr!=0)
{
//if name is already use echo "Le nom $txtnom already usen";
echo $retournom."n";
}
else
{
//create frame echo "<FRAMESET ROWS="100%,0%">n";
echo "<FRAME SRC="frame_ve.php3?txtdir=$txtdir&txtnom=$txtnom" NAME="main_frame"> <!-- main Frame -->n";
echo "<FRAME SRC="nom.php3" NAME="null"> <!-- Frame null -->n";
echo "</FRAMESET>n";
}
}
?>

</HTML>
<BODY BGCOLOR="#FFFFFF">
</BODY>

$retounom is HTML meta commande to reload the page where you choose your name

if you don't understand something ask me (i'm french)

with this code the Frames work but no alertbox apear! But if i play with the BODY tag position i got the invert JAVASCRIPT work and i got no frame ?!?
i cannot understand (maybe there is something that i don't know in HTML TAG ???)

Thanx for you answer

oh excuse i forgot to explain to you something:
in config.inc there are only some var which i use to config connection to MySQL server
(so the problem cannot be here)

again thanx

OUps!!!

the code is not the good one.
sur the JAVASCRIPT will not work i don't put:
onload="cleanup();"
in Body tag (but the probleme still here!)

Hi Bixy

would you please give me a html file as generated by this particular script? Maybe then I can see what's wrong...

Bye,

Marc aka Foddex

------------------
++++++++++++++++++++++++++++++++++++++++
ceterum censeo linguam c++ esse delendam

MouArf !!
I found it !
the error is just a HTML Error:
i try to insert frame between BODY tag (that don't work of course)
you cannot insert frame when the page have a BODY and i need a body to insert JavaScript Event so i found another solution

Thanx for your help, if you need me just call http://www.devshed.com/Talk/Forums/wink.gif










privacy (GDPR)