如何在幻灯片范围后自动提交?

时间:2014-08-31 10:19:50

标签: javascript php jquery html

我想在幻灯片范围之后提交表格,我该怎么做?

http://jsfiddle.net/peap/1upb5nd2/1/

HTML:

<form method="POST" action="">  
<div name = "rangeslider" id="rangeslider" style=" height: 6px; " ></div> 
</form>

SCRIPT:

$(function(){  
  $('#rangeslider').slider({
    range: true,
    min: 0,
    max: 1000,
    values: [ 90, 290 ],
    slide: function( event, ui ) {
      $('#bottomValue').val(ui.values[0]);
      $('#topValue').val(ui.values[1]);
      $('#rangeval').html(ui.values[0]+" - "+ui.values[1]);
    }
  });
});

1 个答案:

答案 0 :(得分:1)

滑块完成移动后,您可以使用'stop'事件提交表单

$(function(){  
  $('#rangeslider').slider({
    range: true,
    min: 0,
    max: 1000,
    values: [ 90, 290 ],
    slide: function( event, ui ) {
      $('#bottomValue').val(ui.values[0]);
      $('#topValue').val(ui.values[1]);
      $('#rangeval').html(ui.values[0]+" - "+ui.values[1]);
    },
    stop: function(event, ui) {
      $('form').submit();          
    },
  });
});

http://jsfiddle.net/1upb5nd2/2/