[eluser]haris244808[/eluser]
Hi there ...
i am working with codeigniter and trying to submit a form and then closing it with javascript...
i have a popup function...that i call from the parent page
Code:
< a href = "[removed]popup('controller/method/variable', 'Click', '400', '400')">Click</a>
and here is the function:
Code:
function reject_popup(url, name, width, height){
var top = parseInt((screen.availHeight / 2) - (height / 2));
var left = parseInt((screen.availWidth / 2) - (width / 2));
var features = "location=1, status=1, scrollbars=1, width=" + width + ", height=" + height + ", top=" + top + ", left=" + left;
window.open(url, name, features);
}
and it opens this form:
Code:
<?php echo form_open('state/validate_rejection/'.$file_results->sender_id.'/'.$this->session->userdata('id').'/'.$file_results->id, array('name'=>'rejection_form', 'id'=>'rejection_form', 'onsubmit'=>'window.forms[0].submit();self.close();')); ?>
<div class="form">
<p>
<label>Write the reason of Rejection?<span class='req'>* Required</label>
<textarea name="remarks" rows="8" max-width:380px " autofocus required></textarea>
</p>
</div>
<!-- End Form -->
<!-- Form Buttons -->
<div class="buttons">
<input type="button" class="button" value="cancel" />
<input name="submit_rejection" id="submit_rejection" type="submit" class="button" value="Send" />
</div>
<!-- End Form Buttons -->
<?php echo form_close(); ?>
as you can see the form action is a url that goes to a controller/method :
here is the method i use
Code:
function validate_rejection(){
$this->form_validation->set_rules('remarks', 'Remarks', 'trim|required');
if($this->form_validation->run() == TRUE){
$sender_id = $this->uri->segment(3) ? $this->uri->segment(3) : 0;
$user_id = $this->uri->segment(4) ? $this->uri->segment(4) : 0;
$file_id = $this->uri->segment(5) ? $this->uri->segment(5) : 0;
//here a function from codigniter model is called, and returns true if query succeded, false if it failed
$rejection = $this->files_model->reject_file($sender_id, $user_id, $file_id);
if($rejection == TRUE){
$this->session->set_flashdata('rejection_succ', 'Rejected Successfully');
//redirect('home');
}
else{
$this->session->set_flashdata('rejection_fail', 'Rejection of file Failed');
}
}
else{
$this->session->set_flashdata('remarks_validation_errors', validation_errors());
}
}
and if the form is submitted successfully or failed it will set a flashdata
NOW I WANT THAT WHEN THE FORM IS SUBMITTED TO CHECK IF FORM IS FINISHED, RELOAD THE PARENT PAGE AND CLOSE THE POPUP....
Can anyone please help me achieve that...it is also a javascript case, but as long as i am working with codeigniter i thought that this will be the best place to post this thread?