0

I have table which is created dynamically i need to pass id attribute with numeric value to input tag so that i can retrieve the input filed value. I used for Each tag to loop code snippet:

<c:forEach items="${map}" var="entry">
<tr>
    <td>${entry.key}</td> // first t d filed 
    <td><input id="${id}" type="text" value="${entry.value}" size="50" /></t d> // second t d field with value 
</tr>
</c:for Each>   

I need something like this :
<input id="2" type="text" value="value" size="50" />
how can do this?can someone suggest me.
2
  • Use a variable and increment it inside loop and assign it as id. Commented Oct 6, 2016 at 12:17
  • thanks Rahman can u please share some example . Commented Oct 6, 2016 at 12:20

1 Answer 1

1

You can use a variable and assign it to it as Tanjim said- Use it like this-

<c:forEach items="${map}" var="entry" varStatus="Status">
<tr>
<td>${entry.key}</td> // first t d filed 
  <td><input id="${Status.count}" type="text" value="${entry.value}" size="50" /></td>
 </tr>
 </c:forEach>   
Sign up to request clarification or add additional context in comments.

1 Comment

thanks yash i resloved issue. <c:forEach items="${map}" var="entry" varStatus="theCount"> <tr> <td><font color="#6b96db"><b>${entry.key}</b></font></td> <td> <input id="${theCount.count}" type="text" value="${entry.value}" size="50" /> </td> </tr> </c:forEach>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.