I use several HTML5 default sliders in the same page with the following setup:
Output tag in the page changes value when the slider is moved using the oninput event
A change event is triggered once on release
Tested with the latest Chrome and compiles well on a Raspberry with Node and Socket.io.
class="PIDControlSlider"
min="0"
max="1500"
step="1"
id="APIDConKp"
οninput="APIDConKpVal.value=value"/>
class="PIDControlSlider"
min="0"
max="2000"
step="1"
id="APIDConKi"
οninput="APIDConKiVal.value=value"/>
A simple Javascript code creates the listeners. You might need to try different events instead of 'change' in the last line to see what fits you.
window.οnlοad=function()
{
var classname = document.getElementsByClassName("PIDControlSlider");
var myFunction = function() {
var attribute = this.getAttribute("id");
//Your code goes here
socket.emit('SCMD', this.getAttribute("id")+' '+ this.value);
};
for(var i=0;i
classname[i].addEventListener('change', myFunction, false);
}
}