Maybe someone will tell and tell: I can not understand why the event does not work. I use the standard jquery slider (slider) in the first box tied to the input. When you select the radio and manually enter the input value, everything is ok, but when you move the slider, the value in the input changes, but it does not work.

<input type="text" id="quantity" onchange="clc();" class="quantity" name="quantity"> <div id="slider-gorizontal"></div> <input type="radio" name="thickness" onchange="clc();" class="choiceBtn thickness" value="260" checked="checked">Стандартная: 0.4 мм</input> <input type="radio" name="thickness" onchange="clc();" class="choiceBtn thickness" value="335">Утолщенная: 0.5 мм</input> function clc() { var q = $('#quantity').val(); var t = $('.thickness:checked').val(); $.ajax({ url: 'calc.php', type: 'POST', data: {quantity:q, thickness:t}, dataType: 'json', success: function ( data ) { console.log ( data ) ; if(t == 260) { $('#result').empty(); $('#result').append(data); } else{ $('#result2').empty(); $('#result2').append(data); } } }); } $( function() { $( "#slider-gorizontal" ).slider({ range: "min", min: 0, max: 1000, value: 500, slide: function( event, ui ) { $( "#quantity" ).val( ui.value ); } }).height('10'); $( "#quantity" ).val( $( "#slider-gorizontal" ).slider( "value" ) ); } ); 
  • Let's slider hanging code - br3t

1 answer 1

Programmatically changing the value of the input does not raise onchange events. To see this, try:

 <input id='test' onchange='console.log(value);' /> <button onclick="document.getElementById('test').value='aaa';">Click</button> 

Use the slider's change event: http://api.jqueryui.com/slider/#event-change