dtamho6404 2014-09-12 18:58
浏览 49

无法在PHP中获取提交按钮的值

I need some help getting the value of a submit button. The code below fires off my controller function, but I am unable to get the value of the 'Invite' button. var_dump states 'bool(false)' and a 0 for Educator_Id is inserted into my final query to the database.

Thanks for any help you can give!

My submit button:

<?php foreach($educators as $educator): ?>
    <button type="submit" id="Invite" name="Invite" value="<?php echo $educator->Educator_Id; ?>">Invite</button>
<?php endforeach; ?>

My jQuery function:

$("#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;
})

My controller:

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;
}

My model:

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);
}
  • 写回答

3条回答 默认 最新

  • duanliaolan6178 2014-09-12 19:12
    关注

    Try to passing the value to a hidden input

    JavaScript:

    $("#Invite").live("click", function(){
      var this_value = $(this).val();
      $("input[name='InviteValue']").val(this_value);
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画