Question

Im trying to use 2 different functions for onChange event as follows:

<html:select  property="distributionCategoryCode" tabindex="5"   onchange="<c:choose><c:when test="${model.editT == true}">enableTextboxDirect('${model.dtxtrmks}');</c:when><c:otherwise>enableTextboxDirect();</c:otherwise></c:choose>" >

But getting JSP error as follows:

Expecting quoted value, got character: = Attribute: ${model.editTaxes is not a valid attribute name Expecting quoted value, got character: t

Any inputs?

Was it helpful?

Solution

You can't arbitrarily nest JSP tags like that, it's not legal JSP (or XML).

You need to set the value separately.

In this case I barely see a reason to special-case it in the rendered output, instead pass two parameters to enableTextboxDirect. I don't see a usecase for doing it any other way.

<html:select property="distributionCategoryCode"
             onchange="enableTextboxDirect(${model.editT}, '${model.dtxtrmks}')>

Even if you had to write a one-liner JS wrapper in case you cannot modify enableTextboxDirect it's still a better solution than bothering to change the entire attribute.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top