Jump to content

Recommended Posts

what i'm trying to do is get the contents of the textarea, which the id is 'reply'. 

 

then onclick of a button, a popup div with id 'layer1' displays the contents of the textarea.

 

i tried below but it comes up blank. i haven't included the pop up/button code, thats working.

 

 
<textarea name="reply" id="reply">testing</textarea>
<div id="layer1"></div>


var newtext2 = document.getElementById('reply').value;  
   document.getElementById('layer1').innerhtml = newtext2;

 

 

so onclick of the button it should display "testing" in the div.

Link to comment
https://forums.phpfreaks.com/topic/192789-display-textarea-content-in-div/
Share on other sites

here is the full code.  I just want the contents of the textarea to appear in the pop up div. this isn't working though.

 

<html>
<head>
<style type="text/css">
#layer1 {
position: absolute;
visibility: hidden;
width: 300px;
height: 300px;
	margin-left: 50%;
margin-right: 50%;




background-color: #000000;
border: 1px solid #FBB917;
padding: 10px;

}
#close {
float: right;
font-family:Arial, Helvetica, sans-serif;
}</style>
	<title>Live Help</title>
<script type="text/javascript">
<!--


x = 20;
y = 70;
function setVisible(obj)
{
obj = document.getElementById(obj);
obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';

var obj = ( function( thisId ) {
	var myObj = document.getElementById( thisId ) || document.all[ thisId ];
		return myObj;
		} );
	var newtext2 = obj( "reply" ).value;
		obj( "layer1" ).innerHTML = (( newtext2 ) ? newtext2 : "null" );
}
function placeIt(obj)
{
obj = document.getElementById(obj);
if (document.documentElement)
{
	theLeft = document.documentElement.scrollLeft;
	theTop = document.documentElement.scrollTop;
}
else if (document.body)
{
	theLeft = document.body.scrollLeft;
	theTop = document.body.scrollTop;
}
theLeft += x;
theTop += y;
obj.style.left = theLeft + 'px' ;
obj.style.top = theTop + 'px' ;
setTimeout("placeIt('layer1')",500);


}
window.onscroll = setTimeout("placeIt('layer1')",500);



-->
</script>

</head>
<body>

		<div>

		<textarea name="reply" id="reply" naame="reply" rows="3" 

cols="30">testing</textarea> <input type="button" value="test" onclick="setVisible('layer1');return false' target='_self'" />

<div id="layer1"></div>

		</div>




</body>
</html>

 

it works correctly like this without a popup div..

 

 

<html>
<head>
	<title>Live Help</title>
<script type="text/javascript">
<!--
	var getVal = (function() {

	var obj = ( function( thisId ) {
	var myObj = document.getElementById( thisId ) || document.all[ thisId ];
		return myObj;
		} );
	var newtext2 = obj( "reply" ).value;
		obj( "layer1" ).innerHTML = (( newtext2 ) ? newtext2 : "null" );


	});




-->
</script>

</head>
<body>
	<form id="form1" method="post" action="#" onsubmit="return false;">
		<div>

		<textarea name="reply" id="reply" naame="reply" rows="3" 

cols="30">testing</textarea> <input type="button" value="test" onclick="getVal();" />
<div id="layer1"></div>

		</div>



	</form>

</body>
</html> 

First off you have a problem with matching your quote marks in the input tag:

<input type="button" value="test"
onclick="getVal(); setVisible('layer1');return false' target='_self'" />

You open the onclick with a double quote, but try and close with a single quote. There is also an extra double quote at the end of the target parameter.

 

Second, "name" has only one "a", not two

<textarea name="reply" id="reply" naame="reply" rows="3" 

 

That should fix most of your problems except one. This line

window.onscroll = setTimeout("placeIt('layer1')",500);

 

is failing with the error message "Not implemented".

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.