Posting a value to html from esp-idf code #69
-
Hi Mair, I have an app that generates a web page with input box and button. Users can enter a value and click button and my "C" code handler and script gets the value ok. But I want to be able to display the last value saved when url is first hit and after a new value is entered. At the moment my html code and script looks like below
const range_value = document.getElementById("range"); async function getRangeValue() { |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
Hi @orbitcoms |
Beta Was this translation helpful? Give feedback.
-
I followed the video and could not see anywhere how to update a label on the ESP32 html generated web page on first hit of url. For update I can add a script or alter my html code to update value of label each time number box changes but still cannot figure out how to set the label value on first. I found script that changes label but not sure how to set with my "C" code value (called "range") upon first ht of url. Also, not sure of how to implement and "on_change" function for the number box to do a similar thing function changeLabeltext() |
Beta Was this translation helpful? Give feedback.
-
Thanks Mair That link shows how to manually write text to a label. I need to know how to change the label text when the number input value changes So, a user browses the site and sees the last saved value. They enter a new value in the number box and the label now shows the new value. I think I have done something similar in the "slider" app we worked on a while ago, I'll also take a look at that and see if I can learn what I need. |
Beta Was this translation helpful? Give feedback.
-
Mair, I am working through your videos explaining end-points and server pages. In your example you set up a on_get that triggered when browsing to /api/temperature which sent back temperature. The variable I want to update on the site "range" is on "/" url. Do I simply change url to "/" instead of "api/temperature" char *message= "{"range":15}"; Thanks |
Beta Was this translation helpful? Give feedback.
-
Mair, Chrome CONSOLE output... The element I am trying to set is "RANGE-VAL" in HTML
The script is thisbelow... async function getRange(){ getRange(); |
Beta Was this translation helpful? Give feedback.
-
BTW: |
Beta Was this translation helpful? Give feedback.
BTW:
One thing I kept getting confused about was the GET route.
I kept thinking that this was to process url that user entered but with the java script I realize the script is like a trigger that is stimulating an end-point route internally. Then the handler sends back a result that fetch is waiting for.