?
Solved

executing a function with jquery UI slider component

Posted on 2009-07-03
11
Medium Priority
?
587 Views
Last Modified: 2012-05-07
Hi there,

I am new to jquery and have a basic understanding of its benifits i am trying to add its functionality to my existing site.  I have managed to get this jquery UI slider component plugin working - http://www.filamentgroup.com/lab/update_jquery_ui_slider_from_a_select_element_now_with_aria_support/

I would like the slider to perform a javascript function everytime it changes. With the basic example

<select name="speed" id="speed">
  <option value="Slower">Slower</option>
  <option value="Slow">Slow</option>
  <option value="Med" selected="selected">Med</option>
  <option value="Fast">Fast</option>
  <option value="Faster">Faster</option>
</select>

I would normally add onchange to the select inorder to perform the function when a different value is selected, however with the jquery ui component this does not work. How should I approach this?
0
Comment
Question by:cookiejest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 9

Expert Comment

by:Shahzad Fateh Ali
ID: 24771362
Referring to

http://jqueryui.com/demos/slider/
and
http://www.filamentgroup.com/lab/update_jquery_ui_slider_from_a_select_element_now_with_aria_support/

you can use all native options as 'sliderOptions'

see my code

$('select#valueAA, select#valueBB').selectToUISlider({
				labels: 12,
				// HERE WE GO
                                 sliderOptions:{
					change:function(){
						alert('Hello World');
					}
				}
			});

Open in new window

0
 

Author Comment

by:cookiejest
ID: 24771570
thank you for responding. I have tried:

                  $(function(){
                  $('#posted').selectToUISlider();            
                                // HERE WE GO
                                             sliderOptions:{
                                        change:function(){
                                                alert('Hello World');
                                        }
                                }


            });

But this just gets rid of the slider all together.
0
 
LVL 9

Expert Comment

by:Shahzad Fateh Ali
ID: 24771607
post your html and i will do required modifications
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 

Author Comment

by:cookiejest
ID: 24771637
ok thanks!

<script type="text/javascript">

                  $(function(){
                  $('#posted').selectToUISlider();            
                                // HERE WE GO
                                             sliderOptions:{
                                        change:function(){
                                                alert('Hello World');
                                        }
                                }


            });

      </script>

<p>posted<p>
<select name="posted" id="posted" onchange="paging('1', '','','1', '', this.value, '', '')">
  <option value="" selected="selected">All</option>
  <option value="1246533034"> Less than 24 Hours ago</option>

  <option value="1246446634" >Less than 2 days ago</option>
  <option value="1246360234">Less than 3 days ago</option>
  <option value="1246273834">Less than 4 days ago</option>
  <option value="1246187434">Less than 5 days ago</option>
  <option value="1246101034">Less than 6 days ago</option>
  <option value="1246014634">Less than 7 days ago</option>

  <option value="1245409834">Less than 2 weeks ago</option>
</select>
<p>
0
 
LVL 9

Accepted Solution

by:
Shahzad Fateh Ali earned 2000 total points
ID: 24771758

<script type="text/javascript">
 
                  $(function(){
                  $('#posted').selectToUISlider();            
                                // HERE WE GO
                                             sliderOptions:{
                                        change:function(event,ui){
                                                paging('1', '','','1','', ui.value, '', '');
                                        }
                                }
 
 
            });
 
      </script>
 
<p>posted<p>
<select name="posted" id="posted">
  <option value="" selected="selected">All</option>
  <option value="1246533034"> Less than 24 Hours ago</option>
 
  <option value="1246446634" >Less than 2 days ago</option>
  <option value="1246360234">Less than 3 days ago</option>
  <option value="1246273834">Less than 4 days ago</option>
  <option value="1246187434">Less than 5 days ago</option>
  <option value="1246101034">Less than 6 days ago</option>
  <option value="1246014634">Less than 7 days ago</option>
 
  <option value="1245409834">Less than 2 weeks ago</option>
</select>
<p>

Open in new window

0
 

Author Comment

by:cookiejest
ID: 24771883
hmm, the function still isn't working when the slider is changed. I have changed the function to alert('Hello World'); and it still doesn't work. This is really frustrating.


<script type="text/javascript"> 
 
                  $(function(){
                  $('#posted').selectToUISlider();            
                                // HERE WE GO
                                             sliderOptions:{
                                        change:function(event,ui){
                                                alert('Hello World');                                        }
                                }
 
            });
 
      </script> 
 
 
 
 
<p>posted<p> 
<select name="posted" id="posted"> 
  <option value="" selected="selected">All</option> 
  <option value="1246537227"> Less than 24 Hours ago</option> 
  <option value="1246450827" >Less than 2 days ago</option> 
  <option value="1246364427">Less than 3 days ago</option> 
  <option value="1246278027">Less than 4 days ago</option> 
  <option value="1246191627">Less than 5 days ago</option> 
  <option value="1246105227">Less than 6 days ago</option> 
  <option value="1246018827">Less than 7 days ago</option> 
  <option value="1245414027">Less than 2 weeks ago</option> 
</select> 

Open in new window

0
 
LVL 9

Expert Comment

by:Shahzad Fateh Ali
ID: 24771897
change works when the value in slider changes and it will frustrate if you use alter. do something else with this event 'change'
0
 

Author Comment

by:cookiejest
ID: 24771926
im sorry im not sure i follow you
0
 

Author Comment

by:cookiejest
ID: 24772895
any ideas?
0
 

Author Comment

by:cookiejest
ID: 24772902
can anyone show me an example of this jquery plugin with a function being called everytime there is a change in the slider
0
 

Author Comment

by:cookiejest
ID: 24776441
ok im finally getting somewhere, this code works fine apart from the ui.value seems to output the option number rather than the actual VALUE of the select box. For example in this:

<select name="posted" id="posted">
  <option value="2342342">hello</option>
  <option value="435435" >goodbye</option>
</select>

if goodbye was selected then ui.value = 2 where as i want it to be 435435.
<script type="text/javascript">
 $(function(){
 
$('#posted').selectToUISlider({
labels: 0,
sliderOptions: {
change:function(e, ui) {
paging('1', '','','1', '',ui.value , '', '');
}
}
}); 
}); 
 
 
      </script>
 
 
 
<p>posted<p>
 
 
<select name="posted" id="posted">
  <option value="" selected="selected">All</option>
 
  <option value="1246613721"> Less than 24 Hours ago</option>
  <option value="1246527321" >Less than 2 days ago</option>
  <option value="1246440921">Less than 3 days ago</option>
  <option value="1246354521">Less than 4 days ago</option>
  <option value="1246268121">Less than 5 days ago</option>
  <option value="1246181721">Less than 6 days ago</option>
 
  <option value="1246095321">Less than 7 days ago</option>
  <option value="1245490521">Less than 2 weeks ago</option>
</select>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question