Hi , I am implementing a number spinner which should take value like 1,2,3,4,5,6,7,8,9,10,20,30,40,50,75,100,100+
I am using jQuery UI to implement the spinner
I wanted to know is it even possible to display text values in the spinner…
I have been trying several diff variations of code… to do the job, but to no avail
here is one variation>>>
$(function(){ var ind=0; var qty = Array("1", "2", "3" ,"4" ,"5" ,"6" ,"7","8","9","10","20","30","40","50","75","100","100+"); $('#spinner').spinner({step:1}); $('#spinner').on({"spin":function(e,ui){if(qty[ind+1] > $('#spinner').spinner("value")) { if(ind<qty.length) {$('#spinner').spinner("value",qty[++ind]); } else {$('#spinner').spinner("value",qty[0]); ind=0; } } else if(qty[ind+1] < $('#spinner').spinner("value")) { if(ind > 0) { $('#spinner').spinner("value",qty[--ind]); } else { $('#spinner').spinner("value",qty[qty.length-1]); ind=qty.length-1; } } } }); });
As far as i can see in firebug , this code is changing value of the spinner but for only a split second…as soon as it executes the line
$(‘#spinner’).spinner(“value”,qty[++ind]);
the value changes back to normal spinner value
i have tried using ui.value = qty[++ind]
and $(this).val(qty[++ind])
can anyone tell me whats wrong with my code, or if I am doing it a wrong way, what is the right way to do this?
Thanks.