Page 1 of 1
PHP & JS
Posted: Mon Feb 20, 2006 8:20 pm
by JellyFish
I was wondering if it's ok to use javascript and php in the same script meaning can I have JavaScript in a php file type? The reason I ask this is because I'm trying to do just this. The JS code only makes it say theres an error on the page down in the status bar. All help is appreciated.
Thanks.
Posted: Mon Feb 20, 2006 8:24 pm
by quocbao
I was wondering if it's ok to use javascript and php in the same script
it's ok to use javascript and php in the same script
Code: Select all
<script language=javascript>
alert('Time : <?=date('H:i:s')?>');
</script>
The JS code only makes it say theres an error on the page down in the status bar.
Check your javascript.
Posted: Mon Feb 20, 2006 8:56 pm
by JellyFish
Thanks for your answer. That's all I really needed to know but what is the JS code you gave suppose to do? I think you mean it just displays the error in the status bar. You don't have to answer but I was just wondering.
Posted: Mon Feb 20, 2006 9:35 pm
by josh
That is just an example of alerting time try this:
Code: Select all
<?php
echo '<script language="javascript">';
echo 'alert(\'hello world\');';
echo '</script>';
?>
if it does not work view the source of the page and show us the exact code
Posted: Mon Feb 20, 2006 10:01 pm
by JellyFish
Thanks jshpro2.
Posted: Mon Feb 20, 2006 10:14 pm
by nickman013
How would you JS alert something with a string in it like alert('$blah')
How would I do something like that.
Posted: Mon Feb 20, 2006 10:17 pm
by feyd
play with it a while nickman.
Posted: Mon Feb 20, 2006 10:24 pm
by nickman013
lol im an idiot.
thanks.