Change button on close event of popup
<p>When a user clicks on a button I'd like a popup to open and when I click the accept button in the popup the popup closes. But when it closes, I want to change the button on which the user clicked to open the popup. I have used images instead of buttons. Please advise how can i do it.</p>

<p>Its not working for me.I think you dont get my question."I am clicking on image then popup window opens after accepting whaterver in that popup window again it will show previous window,then that image should change" what should I do for that? Iam sending you updated code here:</p>

<pre><code>&lt;?php
session_start();

if($_SESSION['typeimagedis']=='image/gif') 
        $namedis=$_SESSION['typeimagenamedis'];
        else
    $namedis=$_SESSION['typeimagenamedis'];


    if ($_POST['hidcropimg'] == 'hidcropimg')
{
if(file_exists('images/'.$_SESSION['typeimagenamedis']))
{
unlink('images/'.$_SESSION['typeimagenamedis']);
}
    $targ_w =$_POST['w'];$targ_h = $_POST['h'];
    $jpeg_quality = 20;

if(($_POST['typeimage'] == "image/gif"))
    {
    $src='upload/'.$_SESSION['typeimagenamedis'];
    $img_r = imagecreatefromgif($src);
    }
    if(($_POST['typeimage'] == "image/jpg")|| ($_POST['typeimage'] == "image/jpeg")|| ($_POST['typeimage'] == "image/pjpeg"))
    {
    $src='upload/'.$_SESSION['typeimagenamedis'];
    $img_r = imagecreatefromjpeg($src);
    }


    $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );

    @imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
    $targ_w,$targ_h,$_POST['w'],$_POST['h']);
$yes=1;
if(($_POST['typeimage'] == "image/gif"))
    {
    $name=$_SESSION['typeimagenamedis'];
        imagegif($dst_r,'images/'.$name,$jpeg_quality);
    }
    if(($_POST['typeimage'] == "image/jpg")|| ($_POST['typeimage'] == "image/jpeg") || ($_POST['typeimage'] == "image/pjpeg"))
    {
    $name=$_SESSION['typeimagenamedis'];
        imagejpeg($dst_r,'images/'.$name,$jpeg_quality);
    }

}

    if($_POST['subacc']=='Accept')
    {
    copy('images/'.$_SESSION['typeimagenamedis'],'crop/'.$_SESSION['typeimagenamedis']);
    setcookie ("cronimagename", $_SESSION['typeimagenamedis'], time()+60*60*24*30,'/','iphoneid.com');}
    ?&gt;

    &lt;script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'&gt;&lt;/script&gt;
    &lt;script type='text/javascript'&gt;
    function closewin(){  
    window.close();
    $('#openimg',opener.document).attr('src','/v/vspfiles/photoutility/images/clickheretoTHK_off.gif');
    //alert('openimg');
    }
    &lt;/script&gt;

&lt;?php   

?&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;

        &lt;script src="../js/jquery.min.js"&gt;&lt;/script&gt;
        &lt;script src="../js/jquery.Jcrop.js"&gt;&lt;/script&gt;
        &lt;link rel="stylesheet" href="../css/jquery.Jcrop.css" type="text/css" /&gt;
        &lt;link rel="stylesheet" href="demo_files/demos.css" type="text/css" /&gt;
        &lt;? if($_GET['ref']==1){?&gt;
        &lt;META HTTP-EQUIV="refresh" CONTENT="0; URL=http://serverl.iphoneid.com/demos/croped.php?ProductCode=&lt;?=$_GET['ProductCode']?&gt;"&gt;
&lt;? }?&gt;


    &lt;/head&gt;

    &lt;body&gt;

    &lt;div id="outer"&gt;
    &lt;div class="jcExample" style="width: 802px;height: 1344px;"&gt;
    &lt;table width="151" align="center" style="padding-right:65px;" &gt; 
      &lt;tr&gt;&lt;td width="54"&gt;&lt;form id="frmacc" name="frmacc" method="post" action=""&gt;&lt;input type="submit" id="subacc" name="subacc" value="Accept" onClick="closewin();"  /&gt;&lt;/form&gt;&lt;/td&gt;&lt;td width="238"&gt;
    &lt;form id="frmcancel" name="frmcancel" method="post" action="crop.php?ref=1&amp;ProductCode=&lt;?=$_GET['ProductCode']?&gt;" &gt;&lt;input type="submit" id="subcancel" name="subcancel" value="Select Again"  /&gt;&lt;/form&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
    &lt;div class="article" style="position:relative; margin:70px 0 0 230px;"&gt;
&lt;? if($_GET['ref']==1){
?&gt;
&lt;img  src="wait.gif" width="200px" height="75px"  &gt;
&lt;?
}else{ ?&gt;
        &lt;div style="float:left; height:530px; padding:0px 0 0 0px; width:580px;  background:url(&lt;? if($_GET['ProductCode']=='IPBB'){?&gt;black.png&lt;? }elseif($_GET['ProductCode']=='IPBR'){?&gt;red.png&lt;? }elseif($_GET['ProductCode']=='IPBW'){?&gt;white.png&lt;? }?&gt;) no-repeat; position:relative; z-index:999999999999"&gt;

        &lt;/div&gt;&lt;!--style="padding-top:&lt;?=$padding?&gt;px"--&gt;
        &lt;div align="center"   style=" height: 148px; width: 148px; position:absolute; top:161px; left:61px; z-index:1" &gt;&lt;img  src="images/&lt;?=$namedis?&gt;" height="148" width="148" /&gt;&lt;/div&gt;
&lt;? }?&gt;
    &lt;/div&gt;
   &lt;/div&gt;

    &lt;/div&gt;
    &lt;/body&gt;

&lt;/html&gt;
</code></pre>
