esthera
09-02-2003, 07:39 AM
I have a parent form that opens a modal child form which has in it an iframe. I need to change a value on the parent form from the iframe. Does anyone know how to do this?
|
Click to See Complete Forum and Search --> : changing hidden form value on parent form esthera 09-02-2003, 07:39 AM I have a parent form that opens a modal child form which has in it an iframe. I need to change a value on the parent form from the iframe. Does anyone know how to do this? Khalid Ali 09-02-2003, 09:31 AM this is how you reference the parent form element from a child window top.opener.document.formName.fieldName.value esthera 09-02-2003, 12:34 PM this didn't seem to work. Here's the javascript code html><head> <script language="javascript"> imgSrc='58_11.53471.jpg'; top.opener.document.frmNews.mynewfilename.value=imgSrc; self.parent.close(); </script> without the line top.opener..... the window closes. Once that line is in it doesn't set the variable and the window doesn't close. It's a bit tricy because it is an iframe within the modal window that the parent opened. Do you have any other suggestions? Khalid Ali 09-02-2003, 01:04 PM Originally posted by esthera It's a bit tricy Actually its not.The only thing is that I was missled from your question. What you need to do is follow the parent child hierarchical structur of the document. which goes something like this parent.parent.parent.current so in your quest you wanted to put set a value int he parent document from a child windows child document.. top most child is iframe a level up is the popup window parent.childIframeName.top.opener.document.frameName.fieldname.value is the correct parent child relationship u wanted. esthera 09-02-2003, 01:26 PM thanks for your help but it still didn't seem to go. <html><head> <script language="javascript"> imgSrc='58_83.81486.jpg'; parent.iframeimage.top.opener.document.frmNews.mynewfilename.value=imgSrc; //top.opener.document.frmNews.mynewfilename.value=imgSrc; self.parent.close(); </script> where getimage.asp contains an iframe called iframeimage and gets it's form from getimage2.asp This all posts to addimage.asp which is the document that processes the asp and displays the above javascript. The frmNews is the original form that called the modal window and has a hidden field name called mynewfilename. Any ideas? Esthera Khalid Ali 09-02-2003, 01:48 PM something is not correct at your end,post a link to the pages where it all happens..so that I can take a look esthera 09-03-2003, 12:58 AM it's not up on the web yet but i'll post the relavant code below. Thansk for your help page1 this is in the javascript function doImage() { imageWin=showModalDialog("getimage.asp","","dialogWidth:500px;dialogHeight:430px;status=no;help:no;center:yes") //imageWin = window.open('getimage.asp?myfilename=58_36.88291.jpg'); //imageWin = window.open('getimage.asp?myfilename=58_36.88291.jpg','','width=500,height=430,scrollbars=yes,resiza ble=no,titlebar=1'); //need to wait var imgPath= 'http://u4a2j0/ecalbert/news/pictures/'; //var imgname= '58_36.88291.jpg'; var imgname=document.frmNews.mynewfilename.value var imgSrc=imgPath + imgname; if(imgSrc != null) iView.document.execCommand('insertimage', false, imgSrc); } the form name is frmNews and their is a hidden value of mynewfilename="" get image.asp is the following </head> <body> <iframe name=iframeimage width="100%" height="100%" src="getimage1.asp"></iframe> </form> </body> </html> getimage1.asp is the following <form name=getpicture method=post action=addimage.asp enctype='multipart/form-data'> <table> <tr><td class=admintext>Choose picture to upload:</td></tr> <tr><td class=admintext><input type=file name=picture></td></tr> <input type=hidden name=myfilename value=<%= session("myfilename") %> <Tr><td class=admintext align=left><input type="submit" name="upload" value="Upload"></td></tr> </table> </form> </body> </html> addimage.asp is the following 'uploads picture here is asp <script language="javascript"> imgSrc='1.jpg'; // this is where I need to change the value on the parent form //parent.iframeimage.top.opener.document.frmNews.mynewfilename.value=imgSrc; //top.opener.document.frmNews.mynewfilename.value=imgSrc; self.parent.close(); </script> Thanks, Esther webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |