I have two forms in a page. And I need the form to be submit on single click.
i use below code:
form:
<?php echo $this->Form->create('Payment', array('id' => 'addToDB', 'type' => 'post')); ?>
<?php echo $this->Form->input('merID'); ?>
<?php echo $this->Form->input('card_number', array('label'=>false, 'min'=>16, 'type'=>'select')); ?>
<?php echo $this->Form->input('name_on_card', array('label'=>false, 'type'=>'select')); ?>
<?php echo $this->Form->input('security_code', array('label'=>false, 'type'=>'select')); ?>
<?php $options = array
(
'label' => 'Submit',
'id' => 'submit',
'div' => array(
'class' => 'glass-pill',
)
);
?>
<?php echo $this->Form->end($options); ?>
<?php echo $this->Form->create('Payment', array('id' => 'paymentGateway', 'type' => 'post', 'url' => 'https://uat.pbbank.com/payment/dpayment.jsp')); ?>
<?php echo $this->Form->input('merID'); ?>
<?php echo $this->Form->input('card_number', array('label'=>false, 'min'=>16, 'type'=>'select')); ?>
<?php echo $this->Form->input('name_on_card', array('label'=>false, 'type'=>'select')); ?>
<?php echo $this->Form->input('security_code', array('label'=>false, 'type'=>'select')); ?>
<?php $options = array
(
'label' => 'Submit',
'id' => 'submit2',
'div' => array(
'class' => 'glass-pill',
)
);
?>
<?php echo $this->Form->end($options); ?>
javascrip:
$(document).ready(function () {
$("#submit2").click(function () {
$.post($("#addToDB").attr("action"), $("#addToDB").serialize(),
function () {
alert('Add to Database submitted');
});
$.post($("#paymentGateway").attr("action"), $("#addToDB").serialize(),
function () {
alert('Payment Gateway submitted');
});
});
});
it's work fine on chrome, but not mozilla. Can someone please help me. Thanks in advance.