添加提交表单onchange

I'd like to submit the form when #pname is changed. How can I add submit form to the below?

jQuery(function(){
    jQuery('#pname').on("change", function(){
    var property = jQuery('#pname option:selected').text();
    if (property != 'Any') {
        jQuery('#s').val('Submit1');
    }
    else {
        jQuery('#s').val('');
    }
});

Could I do something like this?

jQuery(function(){
jQuery('#pname').on("change", function(){
var property = jQuery('#pname option:selected').text();
if (property != 'Any') {
    jQuery('#s').val('Submit1');
    jQuery('#s').submit();
}
else {
    jQuery('#s').val('');
}
});

Form id is "s" and dropdown menu is pname.

查看全部
weixin_33738982
?Briella
2015/06/24 15:00
  • submit
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

0个回复