0

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.

Edited by MDanz: n/a

4
Contributors
4
Replies
7
Views
7 Years
Discussion Span
Last Post by jusvin85
0

Hi,
you could try this:

<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>

essential

0

thx alot, i'm trying to get it to work with this though... can you help me to get it to work. Basically just to appear in a pop up div.

<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;

}</style>
		<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" );
		

		});



x = 20;
y = 70;
function setVisible(obj)
{
	obj = document.getElementById(obj);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}
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="getVal(); setVisible('layer1');return false' target='_self'" />

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

			</div>



		
	</body>
</html>

Edited by MDanz: n/a

0
document.getElementById('layer1').innerhtml = newtext2;

I think its failing because that should be innerHTML, not innerhtml.

0

I could bring the text to a div.
My problem is, I need to place the contents of the textarea, in the same format.

for example,

i've two lines in the text area. when i place it in the div, it comes as a single line.

any idea pleace?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.