Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Inverting slider effect

I'm trying to invert the value of the myrange slider. When POS = 0, myrange slider should be at max and when POS = 100, myrange slider should be at minimum. When I use the slider it jumps to high values like: 10089. (number is an int controlled by a rotary encoder. When I use the encoder, the script works flawless, so I suppose I did something wrong in JS.) What did I do wrong?

//Server handling
void mainserver(){
  String POS = server.arg("VOLM");
  number = 100 - POS.toInt();
  delay(15);
  
  displayrendering();
  server.send(200, "text/plane","");
}

void returnpos() {
  String s = String(number, DEC);
  server.send(200, "text/plain", s); //Send web page
}
<div class="slidecontainer">
      <input type="range" min="-100" max="0" value="0" class="slider" id="myrange" onchange="send()">
      <p>Value : <span id="demo">0</span></p>
    </div>

    <script>
      function send() {
        fetch('/setPOS?' + new URLSearchParams({
            VOLM: 100 - document.querySelector("#myrange").value,
        }))
        document.querySelector("#demo").innerText = document.querySelector("#myrange").value;
      }

      const interval = setInterval(function() {
        fetch('/getPOS').then(function(response) {
          return response.text().then(function(text) {
            document.querySelector("#demo").innerHTML = text;
            document.querySelector("#myrange").value = text;
          });
        });
      }, 100);
      
    </script>
    ```
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Rotated the slider 180 degrees with CSS.

      .slider {
        -webkit-appearance: none;
        width: 50%;
        height: 15px;
        border-radius: 5px;
        background: #d3d3d3;
        outline: none;
        opacity: 0.7;
        -webkit-transition: .2s;
        transition: opacity .2s;
        -ms-transform: rotate(180deg); /* IE 9 */
        transform: rotate(180deg);
      }
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!