Hello All,

I am stumbled with one problem regarding HTML Tag Name which is a Varible and I am reassigned it value in runtime.

Actually the Code is something like this.

<%
    String var=null;
    for (int i=0;i<=5;i++) {
          var=(String)i;
     %>
 <div id=var>
 </div>
 <%
   }
  %>

No if I want this div tag to be updated runtime according to the value of the id variable, I am getting id not defined issue.

is there anyone who have resolved this issue??

I knw using javascript we can get dynamic Div tag ID creation, but my solution is more focussed with JSP and I cannot use JavaScript except to get the value of ID by using getElementById() API.

Thanks..

Always use the JSTL

<c:forEach var="count" begin="0" end="5">
   <div id="div_${count}">
   </div>
</c:forEach>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.