?
Solved

I need to pass a domain name into a modal dialog, so it can useit as a parameter

Posted on 2007-07-30
13
Medium Priority
?
224 Views
Last Modified: 2008-01-09
I have two working HTML/JS programs which display a modal dialog, with three radio buttons, each associated with a domain name.   But I need it be more dynamic, and need the ability to pass in a single domain into the modal dialog as a parameter,since it'll be different for each use.

Is this possible?  Could someone who me how?

thanks,
newbieweb

Loader =================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script>
function launch() {
 window.showModalDialog("test.html", window);
}
</script>
</head>
<body>

<input type="button" value="Launch" onClick="launch();">

</body>
</html>

test.html (Modal Dialog) =====================
<HTML>
<HEAD>
<TITLE>Change the URL</TITLE>
</HEAD>
<BODY>
Pick your favorite investment site:<P>
<FORM>
<input type = 'hidden' id=temp1 value='http://www.fool.com/' />
<input type =radio name='MENU1' id='MENU1' onClick='document.getElementById("temp1").value = this.value' value='http://www.fool.com/' checked=true>Fool.com (The Motley Fool)
<input type =radio name='MENU1' id='MENU1' onClick='document.getElementById("temp1").value = this.value' value='http://www.investor.com/' >MoneyCentral Investor
<input type =radio name='MENU1' id='MENU1' onClick='document.getElementById("temp1").value = this.value' value='http://www.thestreet.com/' >TheStreet.com
<p><INPUT TYPE="button" VALUE="Load" onClick='window.location=document.getElementById("temp1").value' /></p>
</FORM>
</BODY>
</HTML>
0
Comment
Question by:newbieweb
  • 6
  • 3
  • 3
  • +1
13 Comments
 
LVL 9

Accepted Solution

by:
sundaramkumar earned 1000 total points
ID: 19597831
if you want to pass a domain to the modal popup window, an easy way is to save the value in a hidden field
and try reading the value from the modal window as

var x = window.opener.document.getElementById('hiddenfieldid').value
0
 

Author Comment

by:newbieweb
ID: 19597851
but how does a different window access the hidden field?
0
 
LVL 7

Assisted Solution

by:ljubiccica
ljubiccica earned 1000 total points
ID: 19597869
You  need something like this (it won't work locally!):

var url = window.location.href;
var url2 = url.split("/",1);
//this is only to check if this is what you need
//document.write(url2);

Greets
Ljubiccica
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:newbieweb
ID: 19597879
I don't get it.

Could you give an example?
0
 
LVL 9

Expert Comment

by:sundaramkumar
ID: 19597888
you are opening the modal dialog from the main page.
so after opening the modal dialog window, from the modal dialog you can access the parent window's fileds as window.opener.document.getElementById('hiddenfieldid').value
0
 
LVL 9

Expert Comment

by:sundaramkumar
ID: 19597896
in the test.html add the code

<body onload="loadvalues()"

add a js function
function loadvalues(){
 var x = window.opener.document.getElementById('hiddenfieldid').value
}

that is it. this will load/get the main window's filed values
0
 
LVL 7

Expert Comment

by:ljubiccica
ID: 19597914
I probably misunderstood you... (i thought you need a domain name dynamicaly )

sundaramkumar showed you already how a different window acceses the hidden field
that is the window.opener. part...

If you need something else, you need to describe things a bit more...

Greets
Ljubiccica
0
 

Author Comment

by:newbieweb
ID: 19597920
I see.

But how do I hide a field in the main page?  (i'm kinda new here)
0
 
LVL 9

Expert Comment

by:sundaramkumar
ID: 19597940
<input type="hidden" id="testfield" value="">

this is like the normal text box
<input type="text" id="testfield" value="">
0
 
LVL 7

Expert Comment

by:ljubiccica
ID: 19597945
You make a form:
<FORM>
<input type = 'hidden' id='testfield' value='' />
</FORM>
0
 
LVL 9

Expert Comment

by:sundaramkumar
ID: 19597966
<HTML>
<HEAD>
<TITLE></TITLE>
<script language="javascript">
function launch() {
 document.getElementById('test').value = "thisismyvalue";
 window.showModalDialog("test.html", window);
}
</script>
</HEAD>

<BODY>
<input type="hidden" id="test"/>
<input type="button" value="Launch" onClick="launch();">
</BODY>
</HTML>

test.html (Modal Dialog) =====================
<HTML>
<HEAD>
<TITLE>Change the URL</TITLE>
<script language="javascript">
function loadvals(){
      var x = window.opener.document.getElementById('test').value
      alert(x);
      
}
</script>
</HEAD>
<BODY onload="loadvals()">
Pick your favorite investment site:<P>
<FORM>
<input type = 'hidden' id=temp1 value='http://www.fool.com/' />
<input type =radio name='MENU1' id='MENU1' onClick='document.getElementById("temp1").value = this.value' value='http://www.fool.com/' checked=true>Fool.com (The Motley Fool)
<input type =radio name='MENU1' id='MENU1' onClick='document.getElementById("temp1").value = this.value' value='http://www.investor.com/' >MoneyCentral Investor
<input type =radio name='MENU1' id='MENU1' onClick='document.getElementById("temp1").value = this.value' value='http://www.thestreet.com/' >TheStreet.com
<p><INPUT TYPE="button" VALUE="Load" onClick='window.location=document.getElementById("temp1").value' /></p>
</FORM>
</BODY>
</HTML>
0
 
LVL 9

Expert Comment

by:sundaramkumar
ID: 19597970
I've posted a sample code for the two pages(main and modal window)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 19598651
Does a showModalDialog HAVE an opener.
I thought it was passed in the dialog Argument:

opener =(window.dialogArgument)?window.dialogArgument:(opener)?opener:null;
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Suggested Courses

839 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