Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with html:select

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Greetings,
I'm having a problem with setting server side values as a parameter to a javascript function that I am calling during an "onchange" event of an html:select that I have.
The line in my jsp is something like this:

<html:select name="stList" property="attempt.attainmentLevel" onchange="javascript:trackChanges( <%=value%> ;" indexed='true'>

The problem with the above line is that when I view source code after my page is rendered is that the dynamic value is not replaced but I see the <%=value%> as it is!

Now as I was debugging, I replaced this with the regular <select> html tag.

<select name="stList" property="attempt.attainmentLevel" onchange="javascript:trackChanges( <%=value%> ;" indexed='true'>

In this case, I am able to see the processed server side value for <%=value%>.

It is important for me to use html:select and if I do that what do I have to do so that I can pass the dynamic server side value to my javascript function?

I hope I have been articulate enough to explain my problem - please let me know if you need further information.

(If this belongs to the JSP forums, then please let me know so that I can move it there.)

Thanks in advance
RS
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
It's usually OK to use a scriptlet in an attribute of a Struts tag, but the policy is "all or nothing". By this, I mean that either the entire attribute must be represented by a scriptlet, or else no part of it can be a scriptlet. So, for example, the following would work:

If your Web application is a Servlet version 2.4 application, Struts does support EL expressions as part of an attribute, so the following would work:

In this case, though, "value" must be a scoped variable(page, request, session, etc.), and not just a Java variable.
 
Raghu Nathan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks for the help
I used the first method and was able to get the function call.

RS
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic