Welcome Guest, Not a member yet? Register   Sign In
How to display a popup window on success of form submit
#1

[eluser]Cgull[/eluser]
Hello,

I have an order form that submits data to the database.

If the form validation is successful, I want to pop up a window that displays the order details for user confirmation before submitting the data to the database.

I have this function in my processOrder controller:

Code:
function process()
{
          $this->load->library('firephp');
          $this->firephp->log('Plain Message');     // or FB::
   $this->firephp->info('Info Message');     // or FB::
   $this->firephp->warn('Warn Message');     // or FB::
   $this->firephp->error('Error Message');   // or FB::
  
   $this -> load -> library( 'form_validation' );
   $this -> form_validation -> set_error_delimiters('<span class="error">', '</span>');
$this -> form_validation -> set_rules( 'date', 'Date', 'required|callback_dateCheck' );
$this -> form_validation -> set_rules( 'time', 'Time', 'callback_timeCheck' );
  $this -> form_validation -> set_rules( 'phone', 'Phone', 'trim|callback_phoneCheck' );
if($this->input->post('customer') == 0)
   $this -> form_validation -> set_rules('name', 'Name', 'trim|callback_nameCheck' );
$this -> form_validation -> set_rules( 'comments', 'Comments', 'callback_checkOrderDets' );  
  
if ( $this -> form_validation -> run() === TRUE )
{
  $this->load->model('mProcessOrder');
  
  $this->mProcessOrder->addOrder();
      
  redirect('home/logout');
}
else
{
  redirect('home');
}
}

And this jquery code in my header_view:

Code:
$("#orderForm").validate({
  errorElement: "span",
   //set the rules for the fild names
   rules: {
   name: { checkName: true },
   phone: { requirePhone: true },
  
     date: {
       required: true,
    checkDate: true
     },
  
   time: { checkTime: true },
  
   comments: { checkOrderDets: true },
  },
  messages: {
     date: { required: "Date is required",},
  },
  //our custom error placement
    errorPlacement: function(error, element) { error.appendTo(element.parent()); }
  });

So in the controller if the validation is successful, I want to pop a window with the order details for the user to confirm. If he confirms, I will submit the data to the database, otherwise, will go back to the order form.

Is that possible with codeigniter? If so, how do I do that?

Thank you,

Sigal




Theme © iAndrew 2016 - Forum software by © MyBB