jQuery [RESOLVED] Trying to set the value of MAX on the slider using a function
Results 1 to 6 of 6

Thread: [RESOLVED] Trying to set the value of MAX on the slider using a function

  1. #1
    Resident Kender kender's Avatar
    Join Date
    May 2004
    Location
    Great Lakes Region, USA
    Posts
    314

    resolved [RESOLVED] Trying to set the value of MAX on the slider using a function

    Okay, I need to fetch the value from another page based on options that are selected, then adjust the max value on my slider to match the value retrieved from the function...

    savvy?

    Any help would be appreciated, I am currently using an alert() to show I am getting the right value, and it is working properly, I just have no idea how to use it outside of the function to set the other value

    HTML Code:
    <script>
    	$(function() {
    		$("#slider").slider({
    			value:0,
    			min: 0,
    			max: 500,  // ***** THIS VALUE ***** //
    			step: 1,
    			slide: function(event, ui) {
    				$("#amount").val(ui.value);  // display number of slider value selected
    			}
    		});
    		$("#amount").val($("#slider").slider("value"));
    	});
    
    	function ajaxItNow() {
    		var date_val = document.getElementById("datepicker").value;    // date
    		var time_val = document.getElementById("scheduleTime").value;  // time
    		var cate_val = document.getElementById("category").value;      // category chosen
    		var zone_val = document.getElementById("region").value;        // region chosen
    
    		$.get("fetch.php", { date: date_val, time: time_val, category: cate_val, zone: zone_val })
    		.done(function(data) {
    			alert("Data Loaded: " + data);  // say data value = 317, then i want to set max to 317
    		});
    	}
    
    </script>
    Now.

  2. #2
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,774
    You want to set the max option after initialising the slider?
    http://api.jqueryui.com/slider/#option-max
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  3. #3
    Resident Kender kender's Avatar
    Join Date
    May 2004
    Location
    Great Lakes Region, USA
    Posts
    314
    Yes, I want the max value to change based off of what the "data" value is (ajax call), which can change based on what values a user selects in other form fields
    Now.

  4. #4
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,774
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  5. #5
    Resident Kender kender's Avatar
    Join Date
    May 2004
    Location
    Great Lakes Region, USA
    Posts
    314
    where would i put the var max = in the code?
    HTML Code:
    	$(function() {
    		var max = $( ".selector" ).slider( "option", "max" );  //* ** doesn't work here ** *//
    		$("#slider").slider({
    			value:0,
    			min: 0,
    			step: 1,
    			slide: function(event, ui) {
    				$("#amount").val(ui.value);
    			}
    		});
    		$("#amount").val($("#slider").slider("value"));
    	});
    
    	function ajaxItNow() {
    		var date_val = document.getElementById("datepicker").value;
    		var time_val = document.getElementById("scheduleTime").value;
    		var cate_val = document.getElementById("category").value;
    		var zone_val = document.getElementById("region").value;
    
    		$.get("fetch.php", { date: date_val, time: time_val, category: cate_val, zone: zone_val })
    		.done(function(data) {
    			$( ".selector" ).slider( "option", "max", data );   //* ** assuming this is where this part goes ** *//
    		});
    	}
    Now.

  6. #6
    Resident Kender kender's Avatar
    Join Date
    May 2004
    Location
    Great Lakes Region, USA
    Posts
    314
    never mind, got it working


    Thanks weedpacket! sometimes all it takes is a swift kick
    Now.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •