File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Frameworks
»
Struts
Author
Transferring data from bean:write to javascript var for textarea
Gayatri Sinha
Ranch Hand
Joined: Feb 13, 2006
Posts: 34
posted
Apr 09, 2007 12:11:00
0
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
Jim Hardin
Ranch Hand
Joined: Aug 02, 2006
Posts: 46
posted
Apr 09, 2007 15:11:00
0
This sounds like a JavaScript "Data-Binding" question. However, something like the following should address your question:
var comments = document.getElementsByName("comments")[0];
-Jim
I agree. Here's the link:
http://aspose.com/file-tools
subject: Transferring data from bean:write to javascript var for textarea
Similar Threads
use javascript variable in JSP?
Double Refresh of JSPs
How to use html:link and javascript:window.open
How to get window.location.hash to work in Fire Fox?
JSP and javascript
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter