Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Passing values between Modal Dialog boxes using Javascript

Posted on 2004-11-24
6
Medium Priority
?
1,907 Views
Last Modified: 2012-06-21
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,
Mike

0
Comment
Question by:HairJam
  • 3
  • 3
6 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12669808
We need to see code.

Cd&
0
 

Author Comment

by:HairJam
ID: 12670338
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">
</form>

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
}
//-->
</script>

<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
%>
</select>
</form>
</body>

-----------------------

Hope this helps, and hopefully I've not left anything out. If it doesn't make any sense though then let me know.
Mike
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 1000 total points
ID: 12670465
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:

http://www.experts-exchange.com/Web/Q_21091733.html
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20447481.html

The the frist one be replaced by a conventional popup using windoow.open() or do you have to have it modal?

Cd&

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:HairJam
ID: 12670914
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.

Thanks,
Mike
0
 

Author Comment

by:HairJam
ID: 12671303
I tried the conventional 'window.open()' 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,
Mike
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12674683
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. :^)

Cd&
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
How do you create a user-centered user experience on your website? And what are some things you should consider in the process?
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question