Welcome Guest, Not a member yet? Register   Sign In
Submitting a form via jQuery...
#1

[eluser]baazil1[/eluser]
I am trying to setup the jquery-ui dialog modal contact form. I have everything working except the submit of the form. I need the submit to access the controller to run through the send email functions I have set up.

My controller has 3 functions and depending on which form is submitted, the specific function will run. So, a user will fill out the help form and click the send button which will then proceed through the jquery validation and then eventually submit back to the controller. This is the part I cannot figure out...

The jquery code:

A button is clicked that opens up the form in a dialog modal window, once the form is filled in and the "Send Form" is clicked, the follow runs:
Code:
$("#facilityForm").dialog({
  autoOpen: false,
  height: 420,
  width: 650,
  modal: true,
  buttons: {
   "Send Form": function() {
    var bValid = true;
    allFields.removeClass( "ui-state-error" );

    bValid = bValid && checkLength( name, "username", 3, 16 );
    bValid = bValid && checkLength( email, "email", 6, 80 );

    if ( bValid ) {
     $("form#helpdeskForm").submit();
     $( this ).dialog( "close" );
    }
   },
   Cancel: function() {
    $( this ).dialog( "close" );
   }
  },
  close: function() {
   allFields.val( "" ).removeClass( "ui-state-error" );
  }
});

The form id is helpdeskForm and when Send Form is clicked, the modal window disappears (assuming $( this ).dialog( "close" ); is working). The problem is, nothing is "submited" to the controller. I need the submit to return to the cantact page and run a specific function in the controller (in this case, it needs to submit to cntact/sendHelpdeskForm so that the function runs, is able to gather the form information (from POST), and sends the email... here is the code for the sendHelpdeskForm function:

Code:
function sendHelpdeskForm () {  

$name = $this->input->post('name');
$email = $this->input->post('email');
$subject = $this->input->post('subject');
$inquiry = $this->input->post('inquiry');
  
$this->email->from('[email protected]', 'Your Name');
$this->email->to($email);
$this->email->subject($subject);
$this->email->message($inquiry);
  
if($this->email->send()) {
  $data = array('title' => 'Form Submitted', 'main_content' => 'pages/formSuccess');
  $this->load->view('template/main', $data);
}
else {
  show_error($this->email->print_debugger());
}

}

Any help? I can clarify things if needed, as I am new to codeigniter and may have gotten some lingo wrong!

Thanks for any assistance!


Messages In This Thread
Submitting a form via jQuery... - by El Forum - 01-27-2012, 08:12 AM
Submitting a form via jQuery... - by El Forum - 01-27-2012, 04:53 PM
Submitting a form via jQuery... - by El Forum - 01-27-2012, 04:59 PM
Submitting a form via jQuery... - by El Forum - 01-27-2012, 05:11 PM
Submitting a form via jQuery... - by El Forum - 01-27-2012, 05:17 PM
Submitting a form via jQuery... - by El Forum - 01-27-2012, 05:33 PM
Submitting a form via jQuery... - by El Forum - 01-27-2012, 05:37 PM
Submitting a form via jQuery... - by El Forum - 01-30-2012, 07:18 AM
Submitting a form via jQuery... - by El Forum - 01-30-2012, 02:53 PM
Submitting a form via jQuery... - by El Forum - 01-30-2012, 03:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB