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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference A tag from pop-up window

Status
Not open for further replies.

GuillermoOZ

Programmer
Sep 24, 2002
8
US
Hey guys, I am trying to have a popup window write something in the opener and couldn't find a good way to do it.
The pop-up window is a form that uploads a file to the server. Upong closing, I am trying to write a < A > that references the file.
It seems I can change the value of a text box by using the form as in:
opener.forms[form].txtbox.value = param;

But instead of a <input > I need to use an anchor. Or at least a label of some sort.

Any ideas? I would much appreciate anybody's help.

Regards,

G
 
You would do it this way.

Popup Menu
Code:
<script type="text/javascript">
<!--// pass the image name to the parent form
function selectImage() {
	var d = document.this_form;
	if (d.file.value) {
		window.opener.loadPreview(d.file.value);
	}
}
//-->
</script>

<form name="this_form">
<input type="text" name="file" value="test-image.jpg">
</form>
Parent page
Code:
<script type="text/javascript">
<!--// create a link to the image
function loadPreview(obj) {
	if (obj)  {
		var span = document.getElementById("preview");

		var text = document.createElement("SPAN");
		text.setAttribute('id','temp');

		var href = document.createElement("A");
		href.setAttribute('id','view');

		var link = "[URL unfurl="true"]http://domain.com/"[/URL] + obj;

		href.setAttribute('href', link);
		href.setAttribute('target','_blank');

		var mesg = "Click Here to View";

		href.appendChild(document.createTextNode(mesg));
		text.appendChild(href);

		span.appendChild(text);
	}
}
//-->
</script>

<span id="preview"></span>

M. Brooks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top