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 9269893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:14:10+00:00 2026-06-18T15:14:10+00:00

I would like to use jQuery to create one slider that allows two different

  • 0

I would like to use jQuery to create one slider that allows two different values to be chosen. I honestly have no idea where to get started.

I’d like for it to display positive values on both sides, but returns two values.

For example:

500———-0———-500

If the slider moves towards the left side, it returns “amount1”. If it moves to the right it returns “amount2”. Both numbers will be positive. I’ve toyed with this for hours to no avail.

Here is the sample code that I’m working with. Is this possible?

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#slider" ).slider({
  value:0,
  min: 500,
  max: 500,
  slide: function( event, ui ) {
    $( "#amount" ).val( "$" + ui.value );
  }
});
$( "#amount1" ).val( "$" + $( "#slider" ).slider( "value" ) );
});
</script>
</head>
<body>

<p>
<label for="amount">Amount</label>
<input type="text" id="amount1" style="border: 0; color: #f6931f; font-weight: bold;" />
<input type="text" id="amount2" style="border: 0; color: #f6931f; font-weight: bold;" />
</p>

Thanks for any input!

  • 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-18T15:14:11+00:00Added an answer on June 18, 2026 at 3:14 pm

    I would go about it like this:

    $(function() {
        $( "#slider" ).slider({
          value:0,
          min: -500,
          max: 500,
          slide: function( event, ui ) {
              if (ui.value > 0){
                 $( "#amount1" ).val( "$" + ui.value );
              }else{
                   //multiply by -1 to make positive
                 $( "#amount2" ).val( "$" + parseInt(ui.value * -1));
              }
          }
        });
    });
    

    DEMO: http://jsfiddle.net/TrgJR/

    Hope this helps and let me know if you have any questions!


    EDIT:

    Here is a cleaned up version.

    Thank you, mrtsherman & Doorknob for your contribution!

    $(function () {
        $("#slider").slider({
            value: 0,
            min: -500,
            max: 500,
            step: 10,
            slide: function (event, ui) {
                if (ui.value > 0) {
                    $("#amount2").val("$" + ui.value);
                    $("#amount1").val("");
                } else {
                    //multiply by -1 to make positive
                    $("#amount1").val("$" + parseInt(ui.value * -1));
                    $("#amount2").val("");
                }
            }
        });
    });
    

    DEMO: http://jsfiddle.net/PXDJb/1/

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

Sidebar

Related Questions

I have two functions I would like to use in my before callback with
I have two similar functions that I would like to combine so that I
I would like to create a search box component, similar to the one that
I would like to ask can one create a page that outputs JSON data
I have an upcoming project that I would like to use the HTML5 canvas
I would like to use jquery to update my attribute value, because I want
We would like to use jquery mobile for all aspects of our site, but
I know this is very basic. I would like to use jQuery to change
I would like to know how can I use jQuery to select multiple items
I would like to .get a page and then use jquery to find elements

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.