• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to passs an attribute of the form to the java script.

 
Akshay Singhvi
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,
I'm struck in a situation. I am fetching a list of bean. One of the attribute of the bean i am displaying as hyperlink. On href of that i have written a javascript function. now i want to pass an unique identifier of that bean to the javascript function. How can i pass that.
see why i am doing this is because in our application we don't want query Strings to be shown when the user put the mouse on the hyper link.Is there a way out to the above problem or to the second problem.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just include either an EL expression or a scriptlet for the bean attribute in your JavaScript code. Example:

<a href="javascript:void(0)" onklick="myFunction('${myBean.myAttribute}')">click here</a>

The above assumes you are running a Servlet 2.4 application that supports EL expressions. If you aren't, you must embed the EL expression in a <cut> tag or use a scriptlet.
 
Arulanand Dayalan
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Struts uou can try this way also.



Hope this helps.

Thanks and Regards,
Arul.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic