I am trying to call the javascript function to fetch the data from DB. when the page loads the other product should fetch the data on click event. But only onclick I is fetching the data and when the page loads first time it is blank page. Please guide me. please find below is my code. java and jsp page
<% for(int i=0;i<vProductLine.size();i++){
if(i == 0) { %>
<%-- <td id="onglet<%= i %>" class="<% if(nOnglet.equals(""+i)) out.print("ongletActif"); else out.print("ongletInactif"); %>" onload="displayOnglet('<%= i %>')"> --%>
<td id="onglet<%= i %>" class="<% if(nOnglet.equals(""+i)) out.print("ongletActif"); else out.print("ongletInactif"); %>" onload="displayOnglet('<%= i %>')">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td nowrap align="center"><b><j2ee:text id="xmlFile" tag="<%= vProductLine.elementAt(i).toString() %>"/></b></td></tr>
<tr><td align="center"><span id="obj_<%= vProductLine.elementAt(i) %>"></span></td></tr>
</table>
</td>
<% }else{ %>
<td id="onglet<%= i %>" class="<% if(nOnglet.equals(""+i)) out.print("ongletActif"); else out.print("ongletInactif"); %>" onclick="displayOnglet('<%= i %>')">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td nowrap align="center"><b><j2ee:text id="xmlFile" tag="<%= vProductLine.elementAt(i).toString() %>"/></b></td></tr>
<tr><td align="center"><span id="obj_<%= vProductLine.elementAt(i) %>"></span></td></tr>
</table>
</td>
<% }} %>
If the solution in the comment doesn't help to solve your problem, another solution is to put a script tag and call your function inside the script, like this:
<% for(int i=0;i<vProductLine.size();i++){
if(i == 0) { %>
<td id="onglet<%= i %>" ...>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td nowrap align="center">...</td></tr>
<tr><td align="center">...</td></tr>
</table>
</td>
<script>
displayOnglet('<%= i %>'); //or wathever you want to do on td's onlaod
</script>
<% }... %>