Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Pass Value from struts Action class to java script

 
smitha mulu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How can we pass count value from struts action class to java script in jsp .. i want to print the count in javascript pop up

in actions class

request.setAttribute("count",count)

in jsp

<script type="text/javascript">

function noofcount(count){



}

</script>


<input type="submit" value="submit" onlclick="return noofcount(count);">

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about what the rendered JavaScript would look like, then write the JSP to create that JavaScript.
 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To replace the value of count with the actual calue in the javascript use the bean:write tag..

ex.



There is only one catch, if count is a number you can keep the above code. If count were a string value.. surround the bean:write with a pair of single quotes (').

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic