如何使用Javascript提交表单?

时间:2014-10-15 02:36:31

标签: javascript jquery twitter-bootstrap

<?php echo Form::open(array('method' => 'post', 'id' => 'form_public')); ?>
<?php echo Form::csrf(); ?>
<?php echo Form::hidden('publish_flag', \Model_Item_Review::PUBLISH); ?>
<?php echo Form::submit('submit',  'submit', array('id'='public'))?>
<?php echo Form::close(); ?>

下面是js代码,模态弹出窗口用于警告。

<button class="btn btn-flat-danger modal-btn-primary btn-block" data-dismiss="modal" id="do_confirm">yes</button>

$('#public').click(function(e){
    e.preventDefault();
    $('#warning_modal').html('are you sure?');
    $('#confirmModal').modal('show');
    $('#do_confirm').click(function(){
        $('#form_public').submit();
    });
});

单击“是”时显示错误:Uncaught TypeError: object is not a function 为什么我无法提交表格?非常感谢。

1 个答案:

答案 0 :(得分:0)

更改此

<?php echo Form::submit('submit',  'submit', array('id'='refuse'))?>

到这个

<?php echo Form::submit('submit',  'submit', array('id'='public'))?>