Search code examples
javascriptjqueryjspstruts2jsp-tags

Assign hidden value using Struts2 tag


How assign the hidden value using Struts tag inside of iteration. My JSP code looks like this:

<s:iterator value="collegelist">
    <s:hidden name="hiddenname" value='<s:property value="collegename"/>'/>
</s:iterator>

It takes hidden field's value as a string it show on alert:

<s:property value="collegename"/>

JavaScript code:

var text = myForm.hiddenname.value;
alert(text);

Solution

  • <s:iterator value="list">
      <s:hidden name="hidden" value="%{property}" />
    </s:iterator>