aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes jQuery - unable to obtain slider values from wrapped set of sliders Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "jQuery - unable to obtain slider values from wrapped set of sliders" Watch "jQuery - unable to obtain slider values from wrapped set of sliders" New topic
Author

jQuery - unable to obtain slider values from wrapped set of sliders

Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Hi there,

I have some jQuery sliders on a web page and I want to get their values and store those values in an Array.

I didn't think this would be a problem as I having been getting the slider values no problem when I have been accessing them as follows:



So I thought the best way to get all the values would be to get a wrapped set of all the sliders and then iterate through this and get all the values as follows:



but it's not working. I've used alerts to debug, and it's the code in the for loop that is the problem. As far as I can see, this code is getting a wrapped set of divs with class 'slider', getting the one at the index of 'i', getting the value of the slider and assigning it to the correct element of the array.

I have used $('div.slider').size() to see that the wrapped set had elements to it and it did, so I am very confused and wonder if anybody can point me in the right direction.

Thank you in advance.

Joe


OCPJP 85%
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

You're kinda doing it inside out.

Rather than apply the loop from the "outside", investigate the use of jQuery's .each() method.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

(and even more relevant to your situation, jQuery's .map() method).
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
get() does not return a jQuery object, it returns the DOM Object

secondly you are getting the value wrong.

http://docs.jquery.com/UI/Slider#methods

Eric

Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Hi Bear and Eric,

Thank you. I found both your replies very helpful and have fixed my problem as a result. I have now have the following (I think) pretty nice code:



Sweet!

Thanks again

Joe
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jQuery - unable to obtain slider values from wrapped set of sliders