I have loaded a number of different examples and am able to switch an LED On and Off with a button on a web page. However when I try and modify the code for my specific application, I just can not seem to make it work. I find too much information on one line which I do not require. I am looking for a simple one liner almost.
The Web page has a table and other information on it, however it is not part of my issue right now.
My project will have some numbers on the screen which are received from a serial port on the ESP8266 , a simple maths formulae is applied to the incoming data, modified and JSON serialized and sent to the web page. I got this working very well, however I would like to have a 2 button selection, more buttons later, in which I can select the fixed value to be used in the maths calculation.
At first I would like to switch an LED on for each option so that I am aware that the specific selection is in effect, then later send a descriptive string to the ESP8266.
On the fly I would like to change the selection by pressing the switches, so that the calculations done in the ESP8266 will use the new factor.
I can get the selection to show on the web page, but I just can not get the information to the ESP8266 as a string and to switch on the specific LEDs.
Here with relevant snippets of the code which are part of the HTML body.
Setting up the buttons to push
<button onclick="get110V()">110V AC</button>
<button onclick="get230V()">230V AC</button>
Respective script to make the changes on web page
<script>
function get110V() {
document.getElementById("rangeValue").innerHTML = "110V AC";
var Range_Selection = "110V AC";
Serial.println(Range_Selection);
digitalWrite(LED_GPIO,LOW);
digitalWrite(LED_GPI1,HIGH);
Serial.println("110V AC");
var xhr = new XMLHttpRequest();
xhr.open("GET", "/" , true);
xhr.send();
};
</script>
<script>
function get230V() {
document.getElementById("rangeValue").innerHTML = "230V AC";
var Range_Selection = "230V AC";
Serial.println(Range_Selection);
digitalWrite(LED_GPIO,HIGH);
digitalWrite(LED_GPI1,LOW);
Serial.println("230V AC");
var xhr = new XMLHttpRequest();
xhr.open("GET", "/" , true);
xhr.send();
Serial.println("230V AC");
};
</script>
When I press the respective button, the place holder which displays the voltage mode calculation, on the web page updates, however, I can not get the LEDs to go on on the ESP8266, and pass the string to the ESP8266.
What am I missing?