SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    submit form then close the popup

    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
    HTML Code:
     < a href = "javascript: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:
    HTML Code:
    [PHP]<?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();')); ?>[/PHP]
    
    			<div class="form">
    
    				<p>
    					<label>Write the reason of Rejection?<span class='req'>* Required</label>
    						<textarea name="remarks" rows="8" style="width:380px; max-width:380px " autofocus required></textarea>
    				</p>
    
    			</div>
    			<!-- End Form -->
    
    			<!-- Form Buttons -->
    			<div class="buttons">	
    
    				<input type="button" class="button" value="cancel" onclick="javascript:self.close();" />
    				<input name="submit_rejection" id="submit_rejection" type="submit" class="button" value="Send" />
    
    			</div>
    			<!-- End Form Buttons -->
    
    		[PHP]<?php echo form_close(); ?>[/PHP]
    as you can see the form action is a url that goes to a codeigniter 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?

  2. #2
    SitePoint Member
    Join Date
    May 2004
    Location
    chennai
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi haris244808 ,
    i do have the same requirement, did you find any solution


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •