3 minutes ago

What is the way to make the same HTML button initiate functions in both HTML and Python?

As a new member of the team with little Python experience, I would greatly appreciate your support and guidance.

My task is to create a web-based Python application that tracks attendance and daily productivity. Here are the steps:

  1. The user must select an activity and click on the "start" button, which begins the timer for that activity.
  2. After completing the activity, the user must click on the "end" button.
  3. Clicking on "end" should trigger the Python code to send the total interval time to a MySQL database.
  4. Next, the application should fetch the data from MySQL and display the total interval time for each activity on the web page.
Although the "end" button is stopping the timer, it is not triggering the sending of data to MySQL and the subsequent data retrieval and display. I have written code for the third and fourth points, but it is not functioning correctly. I require a better understanding of the code and assistance in obtaining the necessary data.

Thank you for your help and guidance.

Kind regards, Irfan M.

3 minutes ago
Verified Answer
As a senior JavaScript developer, I would like to clarify that you mentioned the requirement of sending data to MySQL database using Python code in point 3. Since Python is a server-side language and JavaScript is a client-side language, you cannot use JavaScript code to directly interact with MySQL. Instead, you can make an AJAX request to the server-side script written in Python, which will then interact with MySQL and return the response to the client-side JavaScript code. For the issue with the timer, we would need to see your code to understand the issue properly. However, I would suggest checking whether the timer is actually stopping on clicking the End button and if the start and end times are being recorded correctly. If the issue persists, you can try debugging your code using browser console or any other debugging tool available.