be80be
Well-Known Member
Maybe some one on here knows a little about HTML and LUA . I been playing with this thing for weeks now and learn somethings about this but for some reason I can't get this part figured out. I figured how Lua loads the web page and made a slider that outputs the value of 0 to 100 in 10 steps 0 10 20 so on.
using the debug window in chrome I can see where the value is changing in code but can't for the life of me figure how to cast it to a variable that I can read back to the esp2866 server. Here the code it makes a nice slider on my little server.
Where value showing a change
using the debug window in chrome I can see where the value is changing in code but can't for the life of me figure how to cast it to a variable that I can read back to the esp2866 server. Here the code it makes a nice slider on my little server.
Code:
-- create a server
-- 30s time out for a inactive client
sv=net.createServer(net.TCP, 30)
-- server listen on 80,
-- if data received, print data to console,
-- then send "hello world" to remote.
sv:listen(80,function(c)
c:on("receive", function(c,result)
print(result)
end)
c:send('<!DOCTYPE html>\n')
c:send('<html xmlns="http://www.w3.org/1999/xhtml">\n')
c:send('<head>\n')
c:send('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n')
c:send('<title> HTML5 Slider </title>\n')
c:send('<script type="text/javascript">\n')
c:send('function showValue(num){\n')
c:send('var result = document.getElementById("result");\n')
c:send('result.innerHTML = num;\n')
c:send('}\n')
c:send('</script>\n')
c:send('</head>\n')
c:send('<body>\n')
c:send('<input type="range" id="sliderBar" min="0" max="100" step="10" value="0" onChange="showValue(this.value);"/>\n')
c:send('<div id="result" style="height:20px;width:30px;border:1px solid #999">\n') --this is where it shows the value on chrome
c:send('</div>\n')
c:send('</body>\n')
c:send('</html>\n')
end)
Code:
c:send('<div id="result" style="height:20px;width:30px;border:1px solid #999">\n') --this is where it shows the value on chrome