• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQuery Slider Issue in Value Resetting

 
Amit Vakodkar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to create a Slider for date range, ie from current date to last 3 months. Suppose I have 3months Jan(31 days) - Feb(28) - Mar(31), when i move the slider its displays the value as "Jan <date>", but as soon as I try to go fwd with another month it displays "Feb 32" & so on. I want to know how can I reset the value so that it changes the value with the month.

Please Ignore the IF loop below.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65125
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd do all the "date math" using the Date class and converting all values to milliseconds.
 
Amit Vakodkar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah all the variables you see are getting the values from Date Class in JS, all that is working fine but the issue is with slider value, which i need to change from Jan 31 to Feb 1 & not Feb 32. I have a input box which displays the value of the slider, in my case which displays Date/

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65125
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the Date class to do the date math -- using string concatenation isn't going to work out well.
 
Amit Vakodkar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take the Scenario as: I have a Jquery Slider which has the min as 1 & max as 100. When i move the slider to 31, it should show the msg below as "Jan 31", but as soon as i move to 32 the value which is displayed should show Feb 1, but in my case it is showing Feb 32. Is there any way where in I can reset the value back as 1 at the same time not allowing the slider to move back to the 1st position.

the ui.value in jquery comes as 1...31 32 33 34 ....
below i display as Jan 31

What I need is to change the ui.value such that as soon as it goes beyond 31 it should show the Message as Feb 1.

Eg: UI.Value | Display
31 Jan 31
32 Feb 1
33 Feb 2
34 Feb 3

Bottom line is that I want to show the Calendar dates in Jquery Slider.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit Vakodkar wrote:Take the Scenario as: I have a Jquery Slider which has the min as 1 & max as 100. When i move the slider to 31, it should show the msg below as "Jan 31", but as soon as i move to 32 the value which is displayed should show Feb 1, but in my case it is showing Feb 32. Is there any way where in I can reset the value back as 1 at the same time not allowing the slider to move back to the 1st position.

the ui.value in jquery comes as 1...31 32 33 34 ....
below i display as Jan 31

What I need is to change the ui.value such that as soon as it goes beyond 31 it should show the Message as Feb 1.

Eg: UI.Value | Display
31 Jan 31
32 Feb 1
33 Feb 2
34 Feb 3

Bottom line is that I want to show the Calendar dates in Jquery Slider.


Just keep 2 variables. One that represents the slider value (1-100) and another that represents the day value. Update both when the slider changes.
 
Amit Vakodkar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I change the ui.value which comes from the slider value to display it as a Date corresponding to a particular month. Although I am taking 2 variables the Issue is how to change the Ui.Value to the Date which we need.
Slider Issue.jpg
[Thumbnail for Slider Issue.jpg]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off the cuff, you can't. The ui.value is needed to determine the position of the slider control. If you change it, you manipulate the UI. You need to keep this seperate. You need to calculate the fact that even though the ui.value is 32, your day value is really 1. They have to stay separate. As long as you can always map the ui.value to a date's day, you're good. I don't understand why you think the ui.value needs to match the day value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic