I am using the following JavaScript code to set the value of an element.
document.getElementById('alert['+i+']').innerHTML = "alert";
The element is nested in a Struts set tag. (The ID match up, the fault is not there.)
<s:set var="alert" >
<span id="<s:property value='"alert"+{#stat.index+4}' />"></span>
</s:set>
the set tag var is used by a Struts if tag.
<s:if test="%{#alert == 'alert'}">
//some code
</s:if>
when the span tag is outside of the set tag, the value of the span tag is set to "alert" correctly. However when inside the struts set tag. the span tag cannot be found.
How do I successfully set the value of the set tag? either using the span tag or setting the value of the set tag directly. Or can I somehow inject the "alert" value in the if tag directly?
I have used google and youtube to find answers. I have tried to put the span tag directly in the if tag. I have tried using document.querySelector() but I couldn't get it to work with strut tags.