jsp onclick create  dynamic textarea

Posted on 2011-02-22
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 .
Question by:cofactor
  • 2
LVL 20

Accepted Solution

chaitu chaitu earned 500 total points
ID: 34958706
function ex()
txtsarea=	document.createElement("textarea");


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


Open in new window

LVL 20

Expert Comment

ID: 34958712

Are you after something like this:

<script src="" type="text/javascript"></script>

$(function() {

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


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


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


Open in new window

LVL 20

Expert Comment

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

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

Expert Comment

by:Sathish David Kumar N
ID: 34964878

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
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…

943 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

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now