how to pass variable in url
Posted: Sat Dec 05, 2015 12:13 pm
Goal: read a slider control value in browser and pass it back to ESP8266 server to be used as parameter for pwm of pin.
This code reads the slider and in the last line prints it successfully to the page as a debug step. But the line that puts the x variable in the url results in the url looking like this:
http://192.168.1.174/?somevar= x
And then my Lua program borks at trying to use x as the pwm parameter. I have tried endless methods of converting the var x to a string but so far nothing works. This is my first exposure to javascript.
Can someone tell me how to successfully pass the slider value in the url? Thanks!!!
This code reads the slider and in the last line prints it successfully to the page as a debug step. But the line that puts the x variable in the url results in the url looking like this:
http://192.168.1.174/?somevar= x
And then my Lua program borks at trying to use x as the pwm parameter. I have tried endless methods of converting the var x to a string but so far nothing works. This is my first exposure to javascript.
Can someone tell me how to successfully pass the slider value in the url? Thanks!!!
Code: Select all
conn:send('<script>')
conn:send('function myFunction() {')
conn:send(' var x = document.getElementById("cmd").value;')
conn:send(' document.location.href=\"?somevar= x ";')
conn:send(' document.getElementById("demo").innerHTML = x ;')
conn:send('}</script>')