• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transferring data from bean:write to javascript var for textarea

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is what I am trying to do

I have a jsp page with a textarea
<input type="textarea" name="comments" id="comments" />

Now this data goes into the database and when I do a get on this from the jsp page like

<script type="text/javascript">
var comments = "<bean:write name="myForm" property="comments" scope="request/>";
</script>

Whats happening here is if the user entered data in the textarea with line breaks, in javascript var comments looks like

var comments = This is
a sample
comment;

I get a javascript error here.

Does anyone know how do I get the textarea data from the struts tag into javascript var?

Thanks
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This sounds like a JavaScript "Data-Binding" question. However, something like the following should address your question:


var comments = document.getElementsByName("comments")[0];


-Jim
 
reply
    Bookmark Topic Watch Topic
  • New Topic