Problem Trying to Reset Webserver Form Values

Part 2 of 3

void webserver()
{
  EthernetClient client = server.available();
  // detect if current is the first line
  boolean current_line_is_first = true;

  if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // send a standard http response header
          client.println(F("HTTP/1.1 200 OK"));
          client.println(F("Content-Type: text/html"));
          client.println();
          
          // auto reload webpage every 5 second
          client.println(F("<META HTTP-EQUIV=REFRESH CONTENT=5 URL=>"));

          // background
          //client.println(F("<body background=\"http://img256.imageshack.us/img256/5867/52577012.jpg\"</body>");
            
          //webpage background color
          client.println(F("<body bgcolor=silver>"));

          // webpage title
          client.println(F("<title>Garage Monitor</title>"));

          // webpage heading
          client.println(F("<center><font face='Verdana' color='black' size='8'>Garage Monitor</font></center>"));
          client.println(F("
"));  // line break
          client.println(F("
"));
          client.println(F("<hr>"));  // horizontal line
          client.println(F("
"));
          client.println(F("
"));

          // reset form FAILS!
          //client.println(F("<script>"));
          //client.println(F("<document.form.reset()>"));
          //client.println(F("</script>"));
          //client.println("<body onLoad=javascript:document.forms[0].reset()>");
          //client.println(F("<input type=reset value=Reset Form>"));
          //client.println(F("<form  method=get name=form autocomplete=off>"));
          //client.println(F("<body onload=document.form.reset();>"));
          //client.println(F("<form autocomplete=off>"));
          //client.println(F("<a href=javascript:document.form.reset();>reset</a>"));
          //client.println(F("<script>document.form.reset()</script>"));
          //client.println(F("<script type=text/javascript>"));
          //client.println(F("document.getElementById('b').value ='';"));
          //client.println(F("</script>"));
          
          // button functions
          client.println(F("<form  method=get name=form>"));
          if (DoorPosition == 0){
            //The door is closed
            //client.println(F("<hr><center><a href=http://www.URL.com>URL Link Text</a>
");
            //"<button disabled name=b (to disable a button)
            //font-size:36;color:grey (changes button font color)
            client.println(F("<center><button name=b value=1 type=submit style=height:300px;width:600px;font-size:36;background-color:lightpink>Open Door</button></center>"));
          }
          if (DoorPosition == 1){
            //The door is open
            client.println(F("<center><button name=b value=1 type=submit style=height:300px;width:600px;font-size:36;background-color:lightpink>Open Door</button></center>"));
            client.println(F("
"));
            client.println(F("
"));
            client.println(F("<center><button name=b value=2 type=submit style=height:300px;width:600px;font-size:36;background-color:lightgreen>Close Door</button></center>"));
          }
          if (DoorPosition == 2){
            //The door is open
            client.println(F("<center><button name=b value=1 type=submit style=height:300px;width:600px;font-size:36;background-color:lightgreen>Close Door</button></center>"));
          }
          client.println(F("</form>
"));
          client.println(F("
"));
          client.println(F("<hr>"));

          // Status Panel
          client.println(F("
"));
          client.println(F("<center><font face='Verdana' color='black' size='8'>Status Panel</font></center>"));
          client.println(F("
"));
          client.println(F("<center><font face='Verdana' color='black' size='6'>"));

          // display time
          client.println(String(TimeString));
          client.println(F("
"));

          // display free memory
          client.println("Free Memory: " + String(freeMemory()));
          client.println(F("
"));
          client.println(F("
"));

          // door position
          switch (DoorPosition){
          case 0:
            SecondsOpen = 0;
            MinutesOpen = 0;
            AutoDownEnable = 0;
            client.println(F("Door Position: Closed"));
            client.println(F("
"));
            break;
          case 1:
            client.println(F("Door Position: Middle"));
            client.println(F("
"));
            break;
          case 2:
            if (SecondsOpen == 0){
              TempTime = now();
            }
            MinutesOpen = SecondsOpen / 60;
            client.println("Door Position: Open (" + String(MinutesOpen) + " Minutes)");
            client.println(F("
"));
            delay(1000);
            SecondsOpen = now() - TempTime;
            break;
          case 3:
            client.println(F("Door Position: ERROR!"));
            client.println(F("
"));
            break;
          }

          // door switch status
          if (digitalRead(DoorClosedPin) == HIGH){
            client.println(F("Door Closed Switch: High"));
          }
          else{
            client.println(F("Door Closed Switch: Low"));
          }
          client.println(F("
"));
          if (digitalRead(DoorOpenPin) == HIGH){
            client.println(F("Door Open Switch: High"));
          }
          else{
            client.println(F("Door Open Switch: Low"));
          }
          client.println(F("
"));
          client.println(F("
"));

          // autodown
          AutoDownMinutes = 15;  // 15 minute auto down
          client.println("AutoDown Minutes: " + String(AutoDownMinutes));
          client.println(F("
"));

          AutoDownSwitch = digitalRead(AutoDownEnablePin);
          if (AutoDownSwitch == HIGH){
            client.println(F("AutoDown Enabled: True"));
          }
          else{
            client.println(F("AutoDown Enabled: False"));
          }
          client.println(F("
"));

          if ((DoorOpenState == 1 && AutoDownSwitch == HIGH && MinutesOpen >= AutoDownMinutes) || (AutoDownEnable == 1)){
            AutoDownEnable = 1;
            client.println(F("Close Door: True"));
          }
          else{
            AutoDownEnable = 0;
            client.println(F("Close Door: False"));
          }
          client.println(F("
"));
          client.println(F("
"));
          client.println(F("<hr>"));

          client.println(F("</font></center>"));

          break;
        }
        
        // read form value of "b"
        if (c == '\n') {
          // we're starting a new line
          current_line_is_first = false;
          current_line_is_blank = true;
        } 
        else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
        // get the first http request
        if (current_line_is_first && c == '=') {
          for (int i = 0; i < 1; i++) {
            c = client.read();
            command[i] = c;
          }
          // Relay control
          if (!strcmp(command, "1")){ // && RelayEnable1 == 1) {
            // open door
            digitalWrite(OpenCloseRelayPin1, HIGH); //LOW for relay module
            delay(500);
            digitalWrite(OpenCloseRelayPin1, LOW); //HIGH for relay module
            //RelayEnable1 = 0;
          }
          else if (!strcmp(command, "2")) {
            //close door
          }
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
  }
}