u can use server side scripting instead of javascript.
Use a hidden field variable indicating the current number of rows.
on clicking the ad row button resubmit the page .
the code is like this
<%
int Namecount =0;
String[] values = new String[100];
if (request.getParameter("Namecount") == null){
Namecount = 0
}
else {
Namecount = Integer.parseInt(request.getParameter("Namecount"))+1;
values = request.getParameterValues("agenda");
}
%>
<form name="myForm" method="post" action="Test.jsp">
<input type = "hidden" name="Namecount" value =<%=Namecount%>>
<table width="75%" border="1">
<%
for (int i=0;i<Namecount;i++)
{
%>
<tr>
<td>Name</td>
<td><input type="text" name="agenda" value='<%=values[i]%>'></td>
<td> </td>
</tr>
<%
}
%>
<tr>
<td>Name</td>
<td><input type="text" name="agenda"></td>
<td> </td>
</tr>
</table>
<input type="button" name="submitName" value ="Add More Names" onClick="submitForm()">
then use the javascript function
function submitForm(hiddenValue){
document.myForm.action="TestAddRow.jsp"
document.myForm.submit();
}
Here the code is in jsp. modify this to match with servlets
Niraj Soni <[EMAIL PROTECTED]>@java.sun.com> on 04/05/2001
03:39:54 PM
Please respond to A mailing list about Java Server Pages specification
and reference <[EMAIL PROTECTED]>
Sent by: A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:
Subject: adding row dinamically in tables
hi i have a table generated by servlet like this
<table>
<tbody>
<!--------------row 1------------>
<tr><td><input type=button value="Add row"></td></tr>
<!--------------row 2------------->
<tr>
<td><input type=text name=data></td>
</tr>
<!-------- xxxxxxxx---------->
</tdoby>
</table>
now i want to add new row at the comment xxxxxxxx same as row 2 by
clicking
button Add row
the value entered by user should not be changed
which is good add row at client side using java script or add row at
server
side using servlet ?
have any one has example of inserting row at client side using java
script
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets