This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to include a javascript variable in the value field of param, thanks.

 
Raimann Zhao
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pass a value from the js in one jsp page to struts 2 servlet.

The struts 2 action name is myaction.

In the jsp page, I have below function.

function(){

...

myid=document.getElementById("idValue");
dispName('<s:url value="myaction.action"><s:param name="id" value="myid"/></s:url>');

...

}

In the myaction action class, the id value is null, and I checked it in the Chrome seems myaction.action didn't take id as a param.

If I just replace value="myid" to value="%{'1234'}", I'll get the id value 1234 in myaction class.

Based on it, I guess the only problem is the js variable myid has not been passed to id.

I tried value="myid", value="#myid", value="%{myid}", value="%{#myid}", they all won't work. Almost every possible cases...

Can anybody help me? Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic