Php inside javascript function

Posted by jasminder on Stack Overflow See other posts from Stack Overflow or by jasminder
Published on 2012-06-18T09:05:19Z Indexed on 2012/06/18 9:16 UTC
Read the original article Hit count: 150

Filed under:
|
|

What i am trying to do is inside script tags run javascript inside the php loops. For example:

<script>
$('#mydiv').mouseover(function(){
time();
function time(){
<?php  
    $secs = 45; 
    $secs--;
if($secs <= 25){
?>//javascript code here 
}
});
</script>

My main purpose is when the user mouseover a div, a javascript function runs and inside that javascript function there is php if conitions. If the time is less then 25 then do a specified javascript code. then another condition if the time is less that 10 then do another javascript function.Any type of help will be appreciated. THanks

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript