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();

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

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

Related posts

Recent Viewed