?
Solved

jsp onclick create  dynamic textarea

Posted on 2011-02-22
4
Medium Priority
?
1,204 Views
Last Modified: 2013-11-24
In my jsp , onclick of list items , I would like to create dynamic textarea so that user can type some comments  . How do I do that ?

N.B:  I"m using Struts 2 in the Action class. I would like to  capture the values from the textarea .
0
Comment
Question by:cofactor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 2000 total points
ID: 34958706
function ex()
{
txtsarea=	document.createElement("textarea");
txtsarea.rows='20'
txtsarea.columns='40'
document.body.appendChild(txtsarea);
}

  </script>
 </HEAD>

 <BODY>
india  <input type='checkbox' id='chk' onclick='ex()'>

 </BODY>

Open in new window

0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 34958712

Are you after something like this:

<html>
<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q__26841139.html</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js" type="text/javascript"></script>
<script>

$(function() {

  $(".click-me")
  .click( eventClick )
  .css( { cursor: "hand" } );

});

function eventClick() {
  var id = $(this).attr( "rel" );
  if ( $("#"+id).length == 0 ) {
    $(this).after(
      $("<textarea/>").attr( { id: id } )
    );
  } else {
    $("#"+id).toggle();
  }
}

</script>
</head>
<body>

<ul>
  <li class="click-me" rel="1">Alpha</li>
  <li class="click-me" rel="2">Bravo</li>
  <li class="click-me" rel="3">Charlie</li>
  <li class="click-me" rel="4">Delta</li>
  <li class="click-me" rel="5">Echo</li>
</ul>

</body>
</html>

Open in new window

0
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 34958795
give name to this textarea
txtsarea.name='txtareavalues'
when you click submit button it will call action class

retrieve the textarea in action class
 using request.getParameter("txtareavalues")
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34964878
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question