I've a form that contains several images. Once the user clicks whichever image a popup window with thumbnails is come up. Once he clicks whichever thumbnail, the source image in the parent window needs to replaced according the user selection (swapping the original image). The following script works fine for one image only since logo1 and placeHolder1 variables are hard coded. How can I send the image id from the parent window to the popup window, so the following will be dynamic?
editPage.editForm.logo1.value = oName
editPage. placeHolder1.src = " images/user/" + oName;
BTW, the images name’s and id’s in the main window subject to be changed according the form template.
template.php
<script type="text/javascript">
function logoWin() {
window.open('logos.php','logos','height=500,width=700,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
}
</script>
<form action="" id="editForm" name="editForm" enctype="multipart/form-data">
<img src=”images/user/logo1.jpg” name="placeHolder1" id="placeHolder1" onclick='logoWin()'>
<img src=”images/user/logo2.jpg” name="placeHolder2" id="placeHolder2" onclick='logoWin()'>
<img src=”images/user/logo3.jpg” name="placeHolder3" id="placeHolder3" onclick='logoWin()'>
<input type="hidden" name="logo1" value="<?php echo $main_logo1; ?>" />
<input type="hidden" name="logo2" value="<?php echo $main_logo2; ?>" />
<input type="hidden" name="logo3" value="<?php echo $main_logo3; ?>" />
<input type="submit" value="Save" id="save">
</form>
logos.php
<script language="JavaScript">
function getFile(oImg){
editPage = eval(window.opener.document)
oSrc = oImg.src;
lastSlash = oSrc.lastIndexOf('/');
oName = oSrc.substr(lastSlash+1);
editPage.editForm.logo1.value = oName
editPage. placeHolder1.src = " images/user/" + oName;
this.close()
}
</script>
[php loop]
<img src='images/user/".$row->img_file_name."' onclick='getFile(this)'>
<img src='images/user/".$row->img_file_name."' onclick='getFile(this)'>
<img src='images/user/".$row->img_file_name."' onclick='getFile(this)'>