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

innerHTML and textareas

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016
I'm trying to set the value/innerHTML of a text area in a parent page from a popup. Is there anything obviously wrong with the script below? The first two elements are passing back properly. job_desc is not working with either innerHTML or value. I've double-checked that the id names are correct, and I'm not getting any errors in the FF error console.

Code:
<script type="text/javascript">
function transferTemplate(id) {
	window.opener.document.getElementById('job_mini_desc').value = document.getElementById('job_mini_desc_' + id).value;
	window.opener.document.getElementById('job_title').value = document.getElementById('job_title_' + id).value;
	window.opener.document.getElementById('job_desc').value = document.getElementById('job_desc_' + id).value;
	//window.opener.document.getElementById('job_desc').innerHTML = document.getElementById('job_desc_' + id).value
	//self.close();
}
</script>

The target element is
Code:
<textarea name="job_desc" id="job_desc">
  </textarea>
 
Where is this element defined in your HTML?:
Code:
document.getElementById('job_desc_' + id).value


Can you post that element along with the call to the function transferTemplate?

I don't see anything immediately wrong, but I also don't see all the factors involved.

[monkey][snake] <.
 
Here's the popup html
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Employment Templates</title>
<script type="text/javascript">
function transferTemplate(id) {
	window.opener.document.getElementById('job_mini_desc').value = document.getElementById('job_mini_desc_' + id).value;
	window.opener.document.getElementById('job_title').value = document.getElementById('job_title_' + id).value;
	window.opener.document.getElementById('job_desc').value = document.getElementById('job_desc_' + id).value;
	//window.opener.document.getElementById('job_desc').innerHTML = document.getElementById('job_desc_' + id).value
	//self.close();
}
</script>
<script type="text/javascript" src="../_scripts/common.js"></script>
<link href="admin.css" rel="stylesheet" type="text/css" media="screen">
</head>

<body>
<ul>

	<li id="job_36"><a href="javascript:transferTemplate(36);" id="" >ASSISTANT DISPATCHER W/CLASS 1</a>
	<input id="job_title_36" type="hidden" value="ASSISTANT DISPATCHER W/CLASS 1" />
	<input id="job_mini_desc_36" type="hidden" value="Required in our Edmonton Branch" />
	<input id="job_desc_36" type="hidden" value="test 123" />
	<a href="javascript:sndReq('process_job_template.asp?job_template_id=36&mode=delete','job_36');">delete</a>
	</li>

	<li id="job_37"><a href="javascript:transferTemplate(37);" id="" >HOUSEHOLD GOODS RECEIVER</a>
	<input id="job_title_37" type="hidden" value="HOUSEHOLD GOODS RECEIVER" />
	<input id="job_mini_desc_37" type="hidden" value="Required in our Edmonton Freight Division" />
	<input id="job_desc_37" type="hidden" value="&lt;p&gt;We are currently seeking a summer&amp;nbsp;household goods receiver&amp;nbsp;in our freight&amp;nbsp;division to commence June 1st, 2007.&amp;nbsp; This position will end in August / September.&lt;/p&gt;&lt;h2&gt;Skills and duty requirements include:&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;Professionalism in customer service &lt;/li&gt;&lt;li&gt;Excellent organization and planning abilities&lt;/li&gt;&lt;li&gt;Working with a partner to use dollies and straps to move very heavy items&lt;/li&gt;&lt;li&gt;Breaking down of packing material, folding pads, and other general warehouse duties including..." />
	<a href="javascript:sndReq('process_job_template.asp?job_template_id=37&mode=delete','job_37');">delete</a>
	</li>

</ul>
</body>
</html>
 
I just set up a sample that uses your popup window and it worked perfectly.

Here is what I got for your function (untouched, just removed comments):
Code:
function transferTemplate(id) {
    window.opener.document.getElementById('job_mini_desc').value = document.getElementById('job_mini_desc_' + id).value;
    window.opener.document.getElementById('job_title').value = document.getElementById('job_title_' + id).value;
    window.opener.document.getElementById('job_desc').value = document.getElementById('job_desc_' + id).value;
    self.close();
}

Here is my test HTML file that calls the popup:

Code:
<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
</head>
<body>
   <span id="job_mini_desc"</span>
   <span id="job_title"></span>
   <textarea id="job_desc"></textarea>
   <input type="button" onclick="window.open('test.html', 'popup', 'height=200, width=300')" value="CLICK" /> 
</body>
</html>

The only thing I can think of why your code doesn't work is you may have more than one id = "job_desc"

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top