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

  • SEARCH
  • Home
  • 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 8880307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:08:34+00:00 2026-06-14T20:08:34+00:00

I’m a pretty novice programmer who is trying to make a heartbeat script that

  • 0

I’m a pretty novice programmer who is trying to make a heartbeat script that grabs an id from the current page and sends it to heartbeat.php where the following happens:

1) I look up in the schedule table the currentlocation field that corresponds with the id I just sent over.

2) I then encode the value I found in the currentlocation field in JSON

Here’s the code for heartbeat.php:

<?php
/*** mysql hostname ***/
$hostname = 'localhost';

/*** mysql username ***/
$username = '********';

/*** mysql password ***/
$password = '*********';

$db = new PDO("mysql:host=$hostname;dbname=sv", $username, $password);
$statement = $db->prepare("SELECT currentlocation FROM schedule WHERE apptid = :apptid");
$statement->execute(array(':apptid' => $apptid));
$row = $statement->fetch();
echo json_encode($row['currentlocation']);

?>

On the html side, I am using php for a while loop pulling patient info from the database, so the ID-NUMBER-1 and ID-NUMBER-2 would be the corresponding id’s in the database.

Here’s the html:

<!--  FIRST SET: the id is ID-NUMBER-1  -->

<div class='jcontainer'>
      <div style='display:none; class='jcontainerid'>ID-NUMBER-1</div>
      <button class='checkIn' data-param='button_ID-NUMBER-1'>Check In</button>
      <form method='post' class='myForm' action=''>
           <select name='locationSelect' class='locationSelect' data-param='location_ID-NUMBER-1'>
                <option value='1'>Exam Room</option>
                <option value='2'>Exam Room 2</option>
                <option value='3'>X-Ray Room</option>
                <option value='1000'>Check Out</option>
           </select>
      </form>
      <div class='finished' style='color:#ff0000;'>Checked Out</div>
</div>

<!--  SECOND SET: the id is ID-NUMBER-2  -->

<div class='jcontainer'>
      <div style='display:none; class='jcontainerid'>ID-NUMBER-2</div>
      <button class='checkIn' data-param='button_ID-NUMBER-2'>Check In</button>
      <form method='post' class='myForm' action=''>
           <select name='locationSelect' class='locationSelect' data-param='location_ID-NUMBER-2'>
                <option value='1'>Exam Room</option>
                <option value='2'>Exam Room 2</option>
                <option value='3'>X-Ray Room</option>
                <option value='1000'>Check Out</option>
           </select>
      </form>
      <div class='finished' style='color:#ff0000;'>Checked Out</div>
</div>

So, the problem is, how can I do the following in JQuery:

1) For each jcontainer (or each set of form elements that I marked in my html), grab the id which is the text inside the div with the class of jcontainerid

2) then using a jquery heartbeat, for every 5 seconds the id of each jcontainer sent to the php page and the value of currentlocation sent back in JSON format.

Super thanks for any and all help. If you need any more details cleared up, please just ask and I’ll be happy to help!

  • 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-14T20:08:35+00:00Added an answer on June 14, 2026 at 8:08 pm

    You can use .each() to iterate over each jcontainer, see more here:

    http://api.jquery.com/each/

    Here is an axample of what you can do:

    function dataToHeartbeat(){
      $(".jcontainer").each(function(){
        // grab the id
        var apptid = $(this + " > .jcontainerid").text();
        // Submit to heartbeat.php with JSON expected in return
        $.getJSON('heartbeat.php?apptid='+apptid, function(data){
          // Do something with resulting data
        });
      });
    }
    

    You can then use setTimeout() to call the function. Depending on your needs you can add setTimeout within the function to cause a continuous loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.