The use of the ESP8266 in the world of IoT

User avatar
By mrlightsman
#82118 I can't agree more. Writing my webpage into SPIFFS is the better way to go. But, honestly, I just want to finish the project as is. Then I can go for version 2.0 to see if I can figure out how to do web pages from SPIFFS.

I *think* my last question on this topic is: I have html buttons that I want to use a variable for the "value" attribute... in other words, the button label is a variable.

I have figured that piece out. What I can't figure out is how to allow a space as part of the label. Here is a sample of my code:

Code: Select allString WebPage;
char A_Click[16]; //this variable is populated from an input text on a my webpage.  It is used to create the label of a button on another page.

… lots of code here...

  webPage += "<FORM METHOD=\"POST\"action=\"/A_Click\">";
  webPage += "<input type=\"submit\" style=\"font-size : 35px; width: 50%; height: 100px;font-family: \"Trebuchet MS\", Arial; value=";
  webPage += A_Click;
  webPage += ">";
  webPage += "</form>"


When I run this, the button label shows the content of my variable (rather than "Submit Query") as I would hope. However, I cannot have any spaces. So:

"ClickMeNow" will display as "ClickMeNow" on the button.

"Click Me Now" will display as "Click" on the button.

Anything I can do to the code to allow spaces to be a part of char A_Click and therefore display in the button label?

As always, thanks for the help.
User avatar
By davydnorris
#82122 You need to enclose the value in quotes in the final string - right now you're just writing the variable content with no enclosing quotes:

Code: Select all  webPage += "<input type=\"submit\" style=\"font-size : 35px; width: 50%; height: 100px;font-family: \"Trebuchet MS\", Arial; value=\"";
  webPage += A_Click;
  webPage += "\">";