我需要一些帮助来获取提交按钮的值。下面的代码触发了我的控制器功能,但我无法获得“邀请”按钮的值。 var_dump states'bool(false)',Educator_Id的0被插入到我对数据库的最终查询中。无法获得提交按钮的价值PHP
感谢您的帮助!
我的提交按钮:
<?php foreach($educators as $educator): ?>
<button type="submit" id="Invite" name="Invite" value="<?php echo $educator->Educator_Id; ?>">Invite</button>
<?php endforeach; ?>
我jQuery的功能:
$("#Invite").click(function() {
var form_data = $('#validation-form').serialize();
$.ajax({
url: "<?php echo site_url('schedule/send_invite'); ?>",
type: 'POST',
data: form_data
});
return false;
})
我的控制器:
function send_invite() {
$email = $this->input->post('Educator_Email');
$Opportunity_Id = $this->input->post('Opportunity_Id');
$Educator_Id = $this->input->post('Invite');
$Class_Numbers = $this->input->post('Class_Numbers');
foreach($Class_Numbers as $Class_Number):
$this->ion_auth_model->update_class_educator($Opportunity_Id, $Class_Number, $Educator_Id);
endforeach;
}
我的模型:
function update_class_educator($Opportunity_Id, $Educator_Class, $Educator_Id) {
$Class = array(
'Educator_Id' => $Educator_Id
);
$this->db->where('Opportunity_Id', $Opportunity_Id);
$this->db->where('Class_Number', $Educator_Class);
$this->db->update('Classes', $Class);
}
你不能缩小到PHP或JavaScript?这应该很容易做到。 – 2014-09-12 18:58:37
@JohnConde似乎是一个PHP问题给我。 – 2014-09-12 19:00:26
根据这个答案 - http://stackoverflow.com/a/9866762/689579 - jquery'.serialize()'不编码按钮。 – Sean 2014-09-12 19:08:04