Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8085791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:14:29+00:00 2026-06-05T18:14:29+00:00

What i am trying to do is inside script tags run javascript inside the

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:14:30+00:00Added an answer on June 5, 2026 at 6:14 pm

    JavaScript is client-side script, PHP is server-side script. So, either you do AJAX calls to server or just pure JS.

    AJAX+PHP:

    <script>
        $('#mydiv').mouseover(function(){
            $.ajax({
                url: 'secs.php',
                success: function(data) {
                    var secs = parseInt(data);
    
                    if(secs <= 10) {
                        // do stuff
                    }
                    else if(secs <= 25) {
                        // do stuff
                    }
                },
            });
        });
    </script>
    

    secs.php:

    <?php
        session_start();
    
        if(!isset($_SESSION['secs'])) $_SESSION['secs'] = 45;
        else echo $_SESSION['secs'] --;
    ?>
    

    Pure JS:

    <script>
        var secs = 45;
    
        $('#mydiv').mouseover(function(){
            secs --;
    
            if(secs <= 10) {
                // do stuff
            }
            else if (secs <= 25) {
                // do stuff
            }
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to copy files inside a Python script using the following code: inf,outf
<html> <head> <script type=text/javascript src=jquery.js></script> <script type=text/javascript> $(document).ready(function(){ $(.region).load('getRecords.php?start=regions'); }); </script> </head> <body> <select>
I am trying to run an application inside a Perl script using system() .
I'm trying to fire a php script inside another php script. This is easy,
I'm trying to get the command history inside a shell script. It doesn't work
I'm trying to get text inside .fromTo but the script doesn't work. Do I
I'm trying to deactivate pythonbrew from a bash script. When inside the shell typing
I'm trying to change the href attribute of all the a tags inside an
I am trying to reference a JavaScript file, containing a table sort function, in
I'm trying to write a perl script that removes whitespace from XML tags, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.