Passing values between Modal Dialog boxes using Javascript

Hi all,
I have an HTML page with a link on which calls a Modal Dialog box window. The Modal Dialog box window contains several form fields, however this Modal Dialog window also has a link on which calls another Modal Dialog window which contains a second set of form elements. What I am trying to do is pass data from a field from the second Modal window back into a field on the first Modal window, so that it can in turn be passed back to the HTML page.

So to clarify:
1. HTML Page (page1.html) calls "ModalDialog A".

2. "ModalDialog A" has a textfield within it called "ImageURL", there is also another link which calls "ModalDialog B".

3. "ModalDialog B" has a textfield within it called "txtFileName" and a form button.

When text is entered into "txtFileName" and submitted the value of this textfield needs to be sent back into the textfield "ImageURL" on "ModalDialog A".

Sending values to the HTML page from "ModalDialog A" is fine but I seem to have problems sending values between the two Modal windows - I would have though it was possible though.

Any help would be hugely appreciated.

Many thanks in advance,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

We need to see code.

HairJamAuthor Commented:
Yep ok. I've tried to just give you the relevant code without all the other stuff.

The code that calls the first "ModalDialog A" within the HTML page is as follows:

<input type="button" tabIndex="50" value="Browse" onClick="window.showModalDialog('popups/insert_image.html', '', 'dialogWidth:450px; dialogHeight:315px; center:yes; scroll:no; resizable:no; status:no; help:no;');">


This opens up "ModalDialog A" (insert_image.html) which has several textfields one of which is:
<form id="form1" name="form1">
<INPUT ID="txtFileName2" type=text style="left: 8.54em; top: 6.0647em; width: 21.5em;height: 2.1294em; " tabIndex=10 onfocus="select()" name="ImageURL">

and the second ModalDialog "ModalDialog B" (popup_imagestore.asp) is called by this button next to the above textfield:

<BUTTON ID=btnBrowse style="left: 31.36em; top: 7.5000em; width: 7em; height: 2.2em; " type=button tabIndex=50 onClick="window.showModalDialog('../../popup_imagestore.asp', '', 'dialogWidth:450px; dialogHeight:315px; center:yes; scroll:no; resizable:no; status:no; help:no;');">Browse</BUTTON>


"ModalDialog B" now contains a select box with numerious entries pulled from a database. When the user clicks on an entry I need it to send that value back to "ModalDialog A" and insert it into the textfield called "ImageURL" - this is where I'm stuck.

<script language=javascript>
function SetPreviewImage(strUrl)
  opener.document.Form1.ImageURL.value = strUrl;
 // This is returning 'opener.document' is null or not an object

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" class="orangeBG">
<form name="imageContents">
<select name="FromList" size="12" class="field8"  onClick="SetPreviewImage(this.options[this.selectedIndex].value)">
  Response.Write  strList


Hope this helps, and hopefully I've not left anything out. If it doesn't make any sense though then let me know.
Based on what I see in these two threads you are not going to be able to do it that way.  The first modalDialog cannot retrieve the inforamtion from the second because he is not allowed to be refreshed:

The the frist one be replaced by a conventional popup using or do you have to have it modal?



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

HairJamAuthor Commented:
Ok, I see what you're saying. I can certainly try using a conventional popup for "A" - it might work. I've read the other posts too and they also touch on a similar subject, so thanks for these.

I'll give the popup window a try first and then come back and let you know how I got on.

HairJamAuthor Commented:
I tried the conventional '' route but that didn't resolve any of the problems - more honestly it created some elsewhere in the page.

Still the post you provided has helped me identify that my current route is a non-starter and I'm happy to close the post based on this. I've now looked into combining Modal A and B together and this has allowed me to progress somewhat.

Many thanks,
Sorry I didn't have a magic bullet.  Sometimes the browser manufacturers just don't consider what developers relly need to be able to do.  Thanks for the A. :^)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.