You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Newton <ne...@pingsite.com> on 2005/12/14 16:32:26 UTC

[OT] Re: struts and javascript

fea jabi wrote:

> In my JSP, have to use the defined variable in javascript. How can I 
> use it?
> var totalObj = document.getElementById("total");

Wow, that's so far off I'm not even sure where to start. Marked OT 
because this has more to do with a fundamental misunderstanding of how 
webapps work than anything struts-ish.

JavaScript is run client-side, Struts tags (or any other, for that 
matter) are run server-side. This sounds familiar; did we have a go at 
this once before?

You _could_ do something like (syntax probably wrong; working with other 
technology today):

var total = <c:out value='${total.intValue}'/>;
total += whatever;

and then reference 'total' with a javascript chunk or via any number of 
element replacement techniques on the page.

Does that help?

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org