正在使用 codeigniter 并尝试提交表单,然后用 javascript 关闭它......</p>
我有一个弹出功能……我从父页面调用:
<a href = "javascript:popup('controller/method/variable', 'Click', '400', '400')">Click</a>
这是功能:
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);}
它打开这个表格:
<?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();')); ?>
<p>
<label>Write the reason of Rejection?<span class='req'>* Required</label>
<textarea name="remarks" rows="8" max-width:380px " autofocus required></textarea>
</p>
<input type="button" class="button" value="cancel" />
<input name="submit_rejection" id="submit_rejection" type="submit" class="button" value="Send" />
如您所见,表单操作是一个指向控制器/方法的 url:这是我使用的方法:
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());
}
}
nd 如果表单提交成功或失败,它将设置一个 flashdata
现在我希望在提交表格时检查表格是否完成,重新加载父页面并关闭弹出窗口...... 谁能帮我实现这一点……这也是一个 javascript 案例,但只要我使用 codeigniter,我认为这将是发布此线程的最佳位置?
注意:抱歉格式错误...我是新用户,我没有看到代码块:S