I try to generate some square matrix, and need to send data in post method, I found solution with javascript and form, but all time new form create new line. Othervise I move opening form block out of iteration but it make just 1 variable when i presed on any number, it send always 1 in "place" field.
<%
for (int i = 1; i <= 20; i++) { %>
<form name="submitForm" method="POST" action="buy">
<%
for (int j = 1; j <= 20; j++) {%>
<a href="javascript:;" onclick="parentNode.submit();"> <%=j%> </a>
<input type="hidden" name="row" value="<%=i%>"/>
<input type="hidden" name="place" value="<%=j%>"/>
<% if (j == 20) { %>
<p>
<%}%>
<%}%>
</form>
<%}
%>
Use CSS to make sure the form displays as an inline element, not a block element which has a line-break before and after it.
<style>form { display: inline }</style>
or
<form name="submitForm" method="POST" action="buy" style="display:inline">
Some pitfalls are discussed in How to display HTML <FORM> as inline element? since the open <form>
tag still implies the end of a paragraph element that otherwise appears to contain it.