1

I'm trying to get a web volume slider for a RasPi Project. Therefore I need a way to transfer the value of the slider live to the server. Currently the slider is working fine, but I do not get the data to the server.

I already found a way to do it it via a submit button, but that’s not what I’m looking for because I need the volume “live” at the server.

Best regards geerkins

<script>
function verarbeiten(auswertung){
  //var test = auswertung;
  //alert(test);
  return auswertung;
}
</script>

<form oninput="numerisch.value=verarbeiten(auswertung.value)">
<!--<form oninput="numerisch.value=auswertung.value">-->

  <input type="range" name="auswertung" min="0" max="10" value="5" orient="vertical">
  <br>
  <output name="numerisch">5</output>

</form>
Louys Patrice Bessette
  • 27,837
  • 5
  • 32
  • 57
geerkins
  • 11
  • 3
  • because the volume I needed “live” at the server??? Can you explain more – sumit Jan 09 '18 at 23:51
  • `InputElement.value`?... or... Volume as in ` – StackSlave Jan 09 '18 at 23:56
  • Look for [`.ajax()`](http://api.jquery.com/jquery.ajax/) to send whatever value back to the server, when you want, without page refresh. (But not real-time... Ajax requests have delays... milliseconds) **Now,** I don't see the use-case about having the user's volume at server. – Louys Patrice Bessette Jan 09 '18 at 23:58
  • thanks for the help. When talking about “live” I just wana say that I don’t want to submit any data some milliseconds are nothing to worry about. I need the information at the server because the I use a D/A to control the actual volume of the music playing. (that part is already working) .ajax() seems to be a good start. Will take a look at this tomorrow. – geerkins Jan 10 '18 at 00:09
  • I recommend using the jQuery library, which has some tools ready that you will need: [`.ajax()`](http://api.jquery.com/jquery.ajax/) to send the value to the server, `debounce()` (via [plugin](https://stackoverflow.com/questions/37730628/typeerror-debounce-is-not-a-function)) to make sure you _don't_ send the value 100 times/second. It's of course possible without jQuery, in pure js. – Jeff Jan 10 '18 at 00:36
  • ans [here](https://stackoverflow.com/questions/9713058/send-post-data-using-xmlhttprequest) is some guidance to a version without jQuery - how to send a simple http request to a server. – Jeff Jan 10 '18 at 00:38

0 Answers0