Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:25:15+00:00 2026-06-15T23:25:15+00:00

I have a slider (input type range) that is supposed to run a function

  • 0

I have a slider (input type range) that is supposed to run a function when the value is being changed. The function should then display the new value in a separate div container. After placing an alert in the function, I know that the function isn’t being called, but after googling for an hour and trying a few different methods I just can’t find the error.

Here’s the HTML part:

<input id="slide" type="range" min="1" max="100" step="1" value="10" onchange="updateSlider(this.value)">

<div id="sliderAmount"></div>

JavaScript:

// Slider
function updateSlider(slideAmount)
{
  alert("error");
  var sliderDiv = document.getElementById("sliderAmount");
  sliderDiv.innerHTML = slideAmount;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:25:16+00:00Added an answer on June 15, 2026 at 11:25 pm

    It works, you just need to make sure that the JavaScript function is defined when the element is rendered, for example:

    <script>
        function updateSlider(slideAmount) {
            var sliderDiv = document.getElementById("sliderAmount");
            sliderDiv.innerHTML = slideAmount;
        }
    </script>
    <input id="slide" type="range" min="1" max="100" step="1" value="10" onchange="updateSlider(this.value)">
    <div id="sliderAmount"></div>
    

    See this demo: https://jsfiddle.net/Mmgxg/

    A better way would be to remove the inline onchange attribute:

    <input id="slide" type="range" min="1" max="100" step="1" value="10">
    <div id="sliderAmount"></div>
    

    And then add the listener in your JavaScript code:

    var slide = document.getElementById('slide'),
        sliderDiv = document.getElementById("sliderAmount");
    
    slide.onchange = function() {
        sliderDiv.innerHTML = this.value;
    }
    

    https://jsfiddle.net/PPBUJ/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 1 slider and 1 button: <div data-role=fieldcontain> <input type=range name=slider id=slider value=0
I have an input type=range that is bigger then its parent. I want to
I have a jquery mobile slider : <input type=range name=slider data-track-theme=c data-highlight=true id=slider-step1 step=10000
Here is my code: <input type=range name=slider id=slider value=5 min=0 max=10 step=1 /> All
I have a function that is a JavaScript slider. When its moved, it outputs
I have a range slider and I want it to display values from a
I have a slider, and I'm updating the value internally. But also, user input
At the moment I have a slider and an small input text box which
I have a slider with values 1 - 5. it updates a hidden input
I have Slider in my app that is connected to a few methods. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.