jquery dynamic attribute name

时间:2015-11-12 10:42:17

标签: javascript jquery html jsp

i'm having a list of attribute name like this phonelist1, phonelist2, ect.

I want to render some rows, each row has different phone list I'm trying to get them from my jsp file like this. It's working fine

<td align=left>
    <select value="${phonelist1}"/>
    </select>
    <select value="${phonelist2}"/>
    </select>
    <select value="${phonelist3}"/>
    </select>
</td>
</c:forEach>

However, when I try this. It doesn't work

<c:forEach begin="0" end="${phone_no}" step="1" var="i">
    <select value="${phonelist${i}}"/> --%>
    </select>
</c:forEach>

What can I do to dynamic name the phonelist here?

1 个答案:

答案 0 :(得分:0)

When you are between {} your expression will be evaluated, no need to add an extra set of {}. So just use:

<select value="${phonelist[i]}"/>