Click here to Skip to main content
15,905,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have written following code to get the data from textarea those input by user and show that data on the div(odiv3) after clicking on "ok" button;

its working but the data those paste on div its going unvisible after clicking on button o"ok".

How i can show this data on div ????/
XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Three Div Tags</title>
<script type="text/javascript">
   function addContent(odiv3, data) 
   {
      alert("ddddd");
     document.getElementById(odiv3).innerHTML = data;
 }	 
  </script>
<style>
#odiv1{
	margin:3px;
	
	background-color:#333333;
	height:400px;
	width:460px;
}
#odiv2{
background-color:#0066FF;
margin-left:8px;
    margin-top:15px;  
	
	height:200px;
	width:200px;
	float:left;
		
}
#odiv3{ overflow:Auto;
margin-top:12px;
  
   float:right;
	background-color: #00FF66;
	height:340px;
	width:200px;
	 
}
</style>

</head>

<body>
<form name="form">
<div id="odiv1"><p align="left">odiv1</p>
<div id="odiv2">div2<br>
  <textarea  id="text" cols="20"   rows="5"></textarea>
</br></div>
<div id="odiv3">odiv3<br>
  </br></div>
</div>
<input type="submit" value="ok"  önclick="addContent('odiv3', document.form.text.value);" />
   </form>
</body>
</html>
Posted
Updated 14-Jun-12 9:44am
v4
Comments
Sergey Alexandrovich Kryukov 3-Jun-12 17:15pm    
Can anyone finally answer me: where so many people get "önclick" instead of "onclick"?
--SA
Sergey Alexandrovich Kryukov 3-Jun-12 17:17pm    
How come your style tag is there without any valid attributes?
It should be <style type="text/css"> under the <head> element.
--SA
swapnil66 4-Jun-12 7:30am    
<style type="text/css"> doesn,t matter for this.

I have use text for the id of Textarea id="text";
i want to do this code in Javascript not in jquery..

I just want to show the text written in textarea is on the div when click on ok
Plz run this code you will get what exactly happening..

Thanks
swapnil66 4-Jun-12 4:50am    
<style type="text/css"> doesn,t matter for this.

I have use text for the id of Textarea id="text";
i want to do this code in Javascript not in jquery..

I just want to show the text written in textarea is on the div when click on ok
Plz run this code you will get what exactly happening..

Thanks
Prosan 4-Jun-12 7:00am    
when you click on ok button than your alert message is showing or not.if showing than check what is coming in data.

Where is your name="text"? After all, do it all in jQuery to stop worrying and start programming.
You would get the elements using jQuery selectors and add/modify content/properties using the manipulation group of methods:
http://api.jquery.com/category/selectors/[^],
http://api.jquery.com/category/manipulation/[^].

Please see:
http://en.wikipedia.org/wiki/Jquery[^],
http://jquery.com/[^].

Start here:
http://docs.jquery.com/Tutorials:How_jQuery_Works[^],
http://docs.jquery.com/Tutorials[^],
http://docs.jquery.com/Main_Page[^].

Write less, do more…

—SA
 
Share this answer
 
Comments
VJ Reddy 3-Jun-12 21:16pm    
Good references and suggestion. 5!
Sergey Alexandrovich Kryukov 3-Jun-12 22:46pm    
Thank you, VJ.
--SA
XML
<script  type ="text/javascript" language ="javascript"  >
function showDiv1()
{
document.getElementById('Div1').innerHTML=document.getElementById('TextArea1').value;
return false;
}
    </script>


<input type="submit" id="btn" value="ok" onclick="return showDiv1();" />


use like this i think it will solve ur problem. i have checked it. it is working.
 
Share this answer
 
Comments
swapnil66 5-Jun-12 1:18am    
Thanks Prosan its working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900