You are here:

Javascript/Jquery Slider Calculations

Advertisement


Question
Hello,
(for reference) I'm using this code - http://www.speakingofcode.com/index.php/developer/9-interactive-jquery-price-sli

I need to make a slider output 2 values instead of just one. I've searched all over online and found no help. Is this possible?
I've also tried If/Then statements with no luck. I've tried something like - If slider value = 1, then 2nd value = A. If slider value = 2, then 2nd value = B.

Do you have an idea of what I can do to make 1 slider produce 2 values?
Thanks for any help!

Answer
Hi John,

** Assuming, you are referring to 2 sliders to output 2 values rather than 1 slider to output 2 value ***

In the above example there are 4 sliders right. So what stops you accessing the value of each slider ? Such as ,

$("#amount").val("Type?");
$("#amountb").val("Pages?");

My advice is first of all you have to make sure, whether these sliders returns the values or not. To do that, use a live console like firebug/inspect element console offered by Chrome. Then in it's console tab, directly type your jquery/js code. Such as, when you drag the slider and type $("#amount").val("Type?"); and hit enter. Then the assigned value should display.

Then you can use if-else as you mentioned to narrow down to expected outcome.


** Assuming, you are referring to 2 sliders to output 2 values rather than 1 slider to output 2 value ***


If you want 2 results to set when sliding one slider, first you have to find where the 1 output being set. Then create a new hidden input field and set a value to this newly created hidden input field from the same place where the 1st value being set.

Hope it helps.
Cheers!  

Javascript

All Answers


Ask Experts

Volunteer


Anjana Silva

Expertise

I can answer most of question regarding JavaScripts. Such as how to effectively use JavaScripts in your web page or how we can mix DOM & JavaScript together in our HTML pages. Also I can answer how to validate a form, add dynamic content effects to a web page, menu effects, etc..

Experience

I'm in the field of web development for more than 5 years. I use various JavaScript techniques to fulfill my requirements. I've been using the combination of JavaScript/DOM/HTML effective in my web pages.

Organizations
(1) e-Innoving IT Solutions - Owner (2) OpenArc Business Process Outsourcing - Web Developer

Publications
(1) http://www.anjanasilva.info (2) http://www.e-innoving.info (3) http://www.bestdentistsforless.com/register/register.php

Education/Credentials
(1)Diploma in Information Technology (Currently I'm an undergraduate student of the Bachelor of Information Technology). (2)I've followed courses, workshops on JavaScript.

Past/Present Clients
(1). Legend Maldives PVT Ltd (2). Idama Property Developers & Building Contractors

©2016 About.com. All rights reserved.