String value displayed on <button> as text

Hi,
I'm trying to inject String value into code
The string will change & I'd like the text to change on the button as well.
Pls help.

String Ready = "53s+7s";

 <button class="button" onmousedown="toggleCheckbox('on11');" ontouchstart="toggleCheckbox('on11');" onmouseup="toggleCheckbox('off11');" ontouchend="toggleCheckbox('off11');" String="+ Ready +" </button>

What's that?

Either construct the String by concatenating together the elements you want and then use it or use the elements separately

Personally I have used C style strings (NOTE lowercase s) and used the snprintf() function to replace the value of the %s format character with the string required

It's just a value sent when the button is pressed. This part of the code works ok.
Please see the end of the button line where I'm trying to inject String - usuccessfully.

What kind of value?
(Hint: I know the answer, I'm trying to find out if you do)

Sorry, not sure I understand.
The elements included now are "output", I'm trying to inject string value to appear as text on the button.

Any further hints are welcomed.

@ TheMemberFormerlyKnownAsAWOL you are off topic

I disagree.
What is

('on11')

?

Suppose that you want to send an HTML String like this

    client.print("GET /index.html HTTP/1.1\n\n");

then you could send it like this

   String file = "\index.html";
   client.print("GET ");
   client.print(file);
   client.print(" HTTP/1.1\n\n");

Or you could do this

   String file = "\index.html";
   String request = "GET " + file + " HTTP/1.1\n\n";
   client.print(request);

Either make it easy to change the contents of part of the request

Perhaps I'm not clear on what I'd like to achieve.

How do I reference text assigned to "String Ready", to appear on the button like in the example?

image

String Ready = "53s+7s";

<button class="button" onmousedown="toggleCheckbox('on11');" ontouchstart="toggleCheckbox('on11');" onmouseup="toggleCheckbox('off11');" ontouchend="toggleCheckbox('off11');" >53s+7s</button>

You need 3 Strings as in my previous example
One with all the HTML code before the button text
One with the button text, which may change
One with all the HTML text after the button text

Then you concatenate them together as in my example

I note, however, that you appear to have quotation marks in the button class String and these will need to be escaped using the \ character as otherwise the compiler will see them as the end of the String and an error will occur

@numen2sy
AWOL is trying to help you, flagging his posts to the mods wastes our time and gets you nothing. Please stop flagging trivia.

Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.