user57397: I am fairly new to arduino and ESP though am very familiar with css and javascript.
I have an esp webserver that includes a button
client.print("<button style='background-color: #F30C0C; color:#000;'></button>");

but need it to change the css backbround-color when pin is reading HIGH
 if (c == '\n') {
          currentLineIsBlank = true;
          buffer = "";
        }
        else if (c == '\r') {
          if (buffer.indexOf("GET /?relay1") >= 0)
            relayPIN1read = digitalRead(relayPIN1);

          if (relayPIN1read == HIGH) {
            digitalWrite(relayPIN1, LOW);
          }
          if (relayPIN1read == LOW) {
            digitalWrite(relayPIN1, HIGH);
          }
        }
      }

Does any one know of any way to do this?

user4143: First print everything up to the colour. Then print the colour, which you change depending on the state of the pin. Then print the rest.
client.print("<button style='background-color: ");

if (digitalRead(PIN) == HIGH) {
    client.print("#0CF30C");
} else {
    client.print("#F30C0C");
}

client.print("; color:#000;'></button>");


57397: <p>I am fairly new to arduino and ESP though am very familiar with css and javascript.</p>

<p>I have an esp webserver that includes a button</p>

<pre><code>client.print("&lt;button style='background-color: #F30C0C; color:#000;'&gt;&lt;/button&gt;");
</code></pre>

<p>but need it to change the css backbround-color when pin is reading HIGH</p>

<pre><code> if (c == '\n') {
          currentLineIsBlank = true;
          buffer = "";
        }
        else if (c == '\r') {
          if (buffer.indexOf("GET /?relay1") &gt;= 0)
            relayPIN1read = digitalRead(relayPIN1);

          if (relayPIN1read == HIGH) {
            digitalWrite(relayPIN1, LOW);
          }
          if (relayPIN1read == LOW) {
            digitalWrite(relayPIN1, HIGH);
          }
        }
      }
</code></pre>

<p>Does any one know of any way to do this?</p>
 4143: <p>First print everything up to the colour. Then print the colour, which you change depending on the state of the pin. Then print the rest.</p>

<pre><code>client.print("&lt;button style='background-color: ");

if (digitalRead(PIN) == HIGH) {
    client.print("#0CF30C");
} else {
    client.print("#F30C0C");
}

client.print("; color:#000;'&gt;&lt;/button&gt;");
</code></pre>
