Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to close colorbox within iframe?

i have a page manageGroup.php, where user can also add member to group. I used colorbox to show the addGroupMember.php. Now i need to close that colorbox once i have done submitting the form.

javascript i am using in manageGroup.php

<script language="javascript" type="text/javascript" src="js/jquery-1.3.2.js"></script> <script type="text/javascript" src="js/dropdown.js"></script> <script type="text/javascript" src="js/jquery.colorbox.js"></script> <script type="text/javascript">  $(document).ready(function(){  $(".iframe").colorbox({width:"80%", height:"80%", iframe:true});  }); </script> 

The link i am using to open colorbox

<a class="iframe" href="addGMember.php?id=<?php echo base64_encode($fetch->g_id)?>">Add Member</a> 

the code in addGroupMember.php is like this:-

if($_POST['add']=="Go") {   $gid = $_POST['id'];   $ii=0;   $insert = "INSERT INTO ".DBGMEMBER." (gm_g_id,gm_m_id) VALUES ";   foreach($_POST['gMember'] as $gMember)   {     if($ii==0)     {         $insert .= " ('".$gid."' , '".$gMember."')";     }     else     {         $insert .= " ,('".$gid."' , '".$gMember."')";        }     $ii++;   }   $db->execute($insert);// after this i want to close the colorbox   echo "<script>parent.$.fn.colorbox.close(); </script>";// code i used, but not working } 
like image 825
Ashish Rajan Avatar asked Jan 20 '10 11:01

Ashish Rajan


2 Answers

This one worked out perfectly for me and should work for you

  parent.jQuery.colorbox.close()  
like image 196
Mr_Nizzle Avatar answered Oct 06 '22 12:10

Mr_Nizzle


i got it done for me, a bit crazy way, anyways u can too give it a try.

Supposing your page in iframe as x.php having form named xyz

<?php   if($_post['submit']=='Submit')   {     //some php code here     if(success)      echo "<script>parent.$.fn.colorbox.close(); </script>";     else     {       //some error handling here;     }   } ?> <form name='xyz' action='x.php'>  //some html code here  <input type='Submit' name='submit' /> </form> 
like image 21
Ashish Rajan Avatar answered Oct 06 '22 14:10

Ashish Rajan