Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate text field with link from popup.

Status
Not open for further replies.

cmonster52

Programmer
Joined
Nov 15, 2004
Messages
4
Location
US
Hey,
Trying to use a popup window to help customer select a logo for thier project. The drill down process actually spans 3 pages, and finally they come to a page with an image and a link of the # image they want. I'm trying to get that value of that link to go back to the page where customer started and into a text field. I'm using ColdFusion.
Please help!!!

cmonster52
 
Here's an example to consider:

main.html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]

<html>
<head>
<title>new document</title>

</head>

<body>
  <form name="f">
    <input type="text" name="pic_id" />
	<a href="#" onclick="window.open('choose.html', '', ''); return false;">choose image</a>
  </form>
</body>

</html>

choose.html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]

<html>
<head>
<title>new document</title>

</head>

<body>
  <a href="#" onclick="opener.document.forms['f'].elements['pic_id'].value='1'; return false;">Pic 1</a><br />
  <a href="#" onclick="opener.document.forms['f'].elements['pic_id'].value='2'; return false;">Pic 2</a><br />
  <a href="#" onclick="opener.document.forms['f'].elements['pic_id'].value='3'; return false;">Pic 3</a><br /><br />
  <a href="#" onclick="window.close();">Close Window</a>
</body>

</html>

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
Great,
that seems to work if your only going to one popup page and back.
my problem now is that once I'm on that popup I have two more iframes on that page from drill down of logos.
do I have to carry the form and element variables thru each iframe? if so, how would i go about doing that?

thanks for your time.

cmonster52
 
Could you explain a little better?

The links will be on iframes within the popup window? Is that what you're saying?

If that's the case, you could probably do

[red][tt]parent.opener.document.forms['f'].elements['pic_id'].value='1'[/tt][/red]

And of course, you could write a function to do all of this for you, so that long javascript doesn't have to be in each link. Something like (in the page that sits in the iframe):

Code:
function popMainField(val) {
  var f = parent.opener.document.forms['f'];
  f.elements['pic_id'].value = val;
}

And then call the function in each link, like this:

Code:
<a href="#" onclick="popMainField('1'); return false;">Value 1</a>

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
I'm sorry, i don't know javascript very well, and i'm trying to combine it with ColdFusion. I think you've got the right idea though.

1st page = product_detail.cfm where you have to have an ID passed to view it ... a cfinclude called customize.cfm sits on it. the field for the logo number along with other customizable features is on that customize include. When you click the link to find a logo, you see a popup window. Now, on that window there is a dynamic list of 9 categories. Depending on which one you click another dynamic list of links comes up in an iframe to the right of the first list. Then depending on which link you hit from that list another group of links with images attached comes up in another iframe below the top two lists.

If I bypass the first two category lists and hard-code the variable that shows a specific group of logos, the code from your first response works just fine. But when I try to go thru those dynamic categories, and i drill down to a group of logos, the page seems like it loads back into itself and tells me that there is an error on page.

I hope that clearifies the problem. I really do appreciate your help on this. I've submitted to other forums around the web and no one else has responded, so thank you very very much.

cmonster52
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top