As the title says... Chat on...

User avatar
By bijacz
#57901 Hi everyone,

I'm new here (in ESP8266 too) and I really count on your help. First of all, you need to know that I work on project that check weather and if it is too cold or hot - it lights the LED. I have created form with two "textboxes" in which input type is number. I've also created one submit button. These textboxes are for putting temperature in and now I have to create condition that it will turn LED if value will be out of scope. My question is how to get values from textboxes and put them in (maybe) another function? It this even possible in lua/html?

P.S. Sorry for my english. I hope you understand ;)
User avatar
By bijacz
#57982 Thank you for response. To be clear...

Code: Select allif temp<20
        then
            gpio.mode(5, gpio.OUTPUT)
            gpio.write(5, gpio.HIGH)
        end
   
if temp>22
        then
            gpio.mode(5, gpio.OUTPUT)
            gpio.write(5, gpio.LOW)
        end



Well, i have something like that. Instead of static 20 and 22 I want to get value from this (whatever i put in):

Image

Code: Select all<h4><form action="" method="POST">Min temperature:<br><input type="number" name="min" value="20"><br>Max temperature:<br><input type="number" name="max" value="22"><br></form></h4>\n')
         conn:send('<h5><button name="button" type="submit" formmethod="post" formtarget="_top" onclick="alert("Incorrect values!")">Submit</button><br></h5>\</body></html>')



How to get variables after clicking "submit" and use them in conditions?
User avatar
By marcelstoer
#58003 You can open a server socket and listen for incoming connections (from the browser) using net.server:listen(). That's the foundation you can build upon. You can distinguish between GET requests, for which you'd return the HTML form, and POST requests which would send the form values.

However, you might also want to look into running a ready-made HTTP server: https://github.com/marcoskirsch/nodemcu ... ua-scripts