我有一个表单在蛋糕php这里,我有一些隐藏的字段,我想发送时,用户点击提交按钮。在开始时隐藏字段值为空,您可以在下面给定的形式中看到,我在js文件的playTimer()函数中设置了隐藏字段值
但我的问题是,当我准备提交表单时,post data .Wen中的actionId隐藏字段有空值,我再次点击提交,然后我就有了值。
我想在用户第一次点击提交按钮时设置它,这样我就可以在回调函数之前使用它。
echo $this->Form->create('Meditation', array('id' => 'timerform'));
echo $this->Form->hidden('actionId', array('value'=>'', 'id'=>'actionId'));
echo $this->Js->submit('Play', array(
'before' => 'playTimer();',
'update' => '#map_container',
'complete' => 'setsessionid();',
'success' => 'soundPlay();resume();',
'class' => 'btn btn-med-success playTimer',
'div' => false,
'async' => false,
'url' => array('action' => 'timerupdateDuo')
));
==========Custom.js============
function playTimer(){
$("#actionId").val('playTimer');
}谢谢
发布于 2014-07-04 23:02:58
<? echo $this->Form->submit(__('Save'), array(
'class' => 'ClassOfTheFormSubmitBTN'
)); ?>
<script type="text/javascript">
$(function(){
$('.ClassOfTheFormSubmitBTN').on('click',function(){
// implement your logic here
$('#MODELNAMEactionId').val('something');
//you can use ajax here with serialize to send the form
//to stop the form from posting return false;
});
});
</script>https://stackoverflow.com/questions/24575073
复制相似问题