Automatically unchek a checkbox after a specified amount of time

Hi,
I'm new to programming and to Arduino but I've managed to find this sketch on the internet, that does what I need.

The thing is that I would like this code to include one more feature - to automatically uncheck a checked checkbox, after a specified amount of time has passed since it was checked. And maybe print the time passed, in the webpage after it was checked.

This code will start powering a water heater resistance and I want to be sure I won't forget it ON.

Can you please help me with the code for this feature?

/*--------------------------------------------------------------
  Program:      eth_websrv_LED2

  Description:  Arduino web server that serves up a web page
                allowing the user to control two LEDs
  
  Hardware:     - Arduino Uno and official Arduino Ethernet
                  shield. Should work with other Arduinos and
                  compatible Ethernet shields.
                - LED and resistor in series connected between
                  Arduino pin 2 and GND. Second LED connected
                  to pin 3.
                
  Software:     Developed using Arduino 1.0.3 software
                Should be compatible with Arduino 1.0 +
  
  References:   - WebServer example by David A. Mellis and 
                  modified by Tom Igoe
                - Ethernet library documentation:
                  http://arduino.cc/en/Reference/Ethernet

  Date:         14 February 2013
 
  Author:       W.A. Smith, http://startingelectronics.com
--------------------------------------------------------------*/

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x2B, 0x7B };    // MAC address
IPAddress ip(10,0,0, 20);                               // IP address

EthernetServer server(80);

char char_in = 0;    // used to store a character from the Ethernet port
String HTTP_req;     // stores the received HTTP request

const byte LED_pins[] = {2, 3};          // Arduino pins used as ouputs for LEDs
byte LED[sizeof(LED_pins)] = {0};        // the state of each LED

void setup()
{
    Ethernet.begin(mac, ip);
    server.begin();
    
    // set up the LED pins as outputs
    for (byte index = 0; index < sizeof(LED_pins); index++) {
        pinMode(LED_pins[index], OUTPUT);
    }
}

void loop()
{
    EthernetClient client = server.available();

    if (client) {
        while (client.connected()) {
            if (client.available()) {
                char_in = client.read();  // get a single character from the Ethernet port
                HTTP_req += char_in;      // build a string out of the received characters

                // answer first HTTP request immediately
                if (char_in == '\n') {
                    // respond to HTTP request
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println();
                    CheckLEDs();              // get state of LED checkboxes from web page
                    DisplayLEDs(&client);     // display checkboxes on web & write to LEDs
                    HTTP_req = "";      // delete string contents
                    client.stop();
                } // end if (char_in == '\n')
            } // end if (client.available()
        } // end while (client.connected())
    } // end if (client)
}

// get the state of the LED checkboxes from the HTTP request
void CheckLEDs()
{
    for (byte led_num = 0; led_num < sizeof(LED_pins); led_num++) {
        if ((HTTP_req.charAt(9) == (LED_pins[led_num] + '0')) &&
                    (HTTP_req.charAt(16) == (LED_pins[led_num] + '0'))) {  // LED box is checked
            LED[led_num] = 1;
        }
        else if (HTTP_req.charAt(9) == (LED_pins[led_num] + '0')) {        // LED box is unchecked
            LED[led_num] = 0;
        }
    }
}

// write the HTML that includes the state of the LED checkboxes for displaying on the web browser
void DisplayLEDs(Client *client)
{
    // some CSS in the HTML to change colours and position of the box containing the LED checkboxes
    client->print("<div style=\"background:white; color:green; position: absolute; margin:20px; border: grey solid 2px; padding:0 10px 4px 10px;\">");
    client->print("<h1 style=\"font: normal 20px/150% Verdana, Arial, Sans-serif;\">LED Outputs</h1>");
    // send each LED checkbox in turn
    for (byte led_num = 0; led_num < sizeof(LED_pins); led_num++) {
        // use hidden checkbox so that unchecking a checkbox sends a value to the Arduino
        // if only a normal checkbox is used, nothing is sent when it is unchecked
        // both hidden and normal checkboxes are produced here for each LED
        client->print("<form> <input type=\"hidden\" name=\"LED");
        client->print(LED_pins[led_num], DEC);
        client->print("\" value=\"0\"> <input type=\"checkbox\" name=\"LED");
        client->print(LED_pins[led_num], DEC);
        client->print("\" value=\"");
        client->print(LED_pins[led_num], DEC);
        client->print("\"");
        // write to the LED connected to the Arduino board
        if (LED[led_num]) {
            client->print(" checked ");             // part of HTML if checkbox is to be displayed checked
            digitalWrite(LED_pins[led_num], HIGH);  // switch LED on
        }
        else {
            digitalWrite(LED_pins[led_num], LOW);  // switch LED off
        }
        client->print(" onclick=\"submit();\">LED");
        client->print(LED_pins[led_num], DEC);
        client->print(" </form>");                 // end of HTML for 1 LED's form
    }
    client->print("</div>");                       // end of box containing LEDs
}
String HTTP_req;     // stores the received HTTP request

Start off by pissing away resources needlessly. Good start.

The thing is that I would like this code to include one more feature - to automatically uncheck a checked checkbox, after a specified amount of time has passed since it was checked. And maybe print the time passed, in the webpage after it was checked.

The Arduino can turn a pin off any amount of time, or under any condition, after it turns it on. What it can NOT do is PUSH that change to a client. A client must always PULL new data to see changes.

Thanks for answering.
But if I'm checking that checkbox from my android phone then go to my laptop and load the same URL in the web browser, I can still see it checked.
This is why I figured I can uncheck it from the code, after a specified amount of time, and I would have to manually refresh the browser to see it that it has been unchecked (actually running the needed code as if the it was unchecked from the client).

This is why I figured I can uncheck it from the code, after a specified amount of time

You can change the state of the pin. You can send the new state, reflected as a check box being checked or not, whenever a client asks for a refresh.

You can not make a client request an update, from the server side. You can have the server include meta tags that tell the client to request updates at specified intervals.

I've tried with delay but it doesn't work. I think I should use millis but don't know how. Can you please give a code example?

I've tried with delay but it doesn't work.

You failed to post any code. You failed to describe what actually happened. You failed to describe what you expected to happen. That is what doesn't work!

I think I should use millis but don't know how.

The blink without delay example is one of millions of examples around.

In my opinion, you've also failed at being a nice person and provide a real help to a beginner. I didn't provide any code because I've asked for a code example, I wasn't asking for help with my code.

kostin:
I didn't provide any code because I've asked for a code example, I wasn't asking for help with my code.

This is not a place with a stock of code examples - how could there be? Everyone will want something slightly different.

If you make your best attempt and post your code we will try to help you get it working.

In general a timeout works by saving the value of millis() when the event starts and then regularly checking until the difference between millis() and the saved value exceeds the timeout value. he demo Several Things at a Time illustrates the use of millis() for timing.

In your program you probably need a variable to keep track of the state of the timeout - so you can have a piece of code something like this

   if (timeoutEnded == false) {
        // mark box checked
   }
   else {
       // mark box unchecked
   }

...R