JCO wrote:
Hello,
I'm trying to pass a variable to a javascript function within a onclick
attribute of html:submit tag, but it doesn't resolve the value of the
varieble. This is the code I'm using:

        <%String ent = (String)request.getAttribute("entidad"); %>

        <html:submit property="op" titleKey="boton.ayuda.eliminar" 
onclick="return
eliminar(<%= ent %>)">
                <bean:message key="boton.eliminar" />
</html:submit>
I also have tryied with:

        <%String ent = (String)request.getAttribute("entidad"); %>

        <html:submit property="op" titleKey="boton.ayuda.eliminar" 
onclick="return
eliminar('<%= ent %>')">
                <bean:message key="boton.eliminar" />
</html:submit>
Any idea will be wellcome...

JSP runtime expressions are all-or-nothing: you can't mix an expression and static text in an attribute. You need to make the whole attribute value an expression:

  <html:submit onclick="<%= "return eliminar('" + ent +"')"%>" ...>

Better, switch to JSTL expressions:

  <html:submit onclick="return eliminar('${ent}')" ...>

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to