Capturing a button click in jsp without submitting form
843836Apr 28 2004 — edited May 12 2004hi,
i have a problem with my jsp page. i want to add table rows dynamically to my page upon click of a button using jsp code. in each row i have one combo box and three text boxes.
Is it possible to capture the click of a button on page n upon click execute jsp code to add one more row, without changing the values of text boxes in previous rows n WITHOUT SUBMITTING FORM.
Is there any action listner sort of thin in JSP.
I m using following code : <html:form method="POST" action="dummyaction" >
<div id="show_details" >
<div align="center">
<center>
<table border="0" width="100%" height="59" id="myTable" name="myTable" class="forumline">
<tbody id="myTableTBody" name="myTableTBody">
<tr>
<th width="355" class="row1" height="25" colspan="3">Subject
Details</th>
<th width="598" class="row1" height="25" colspan="3">Difficulty Level Details</th>
</tr>
<tr>
<td width="122" class="row1" height="25">Subject
List:</td>
<td width="204" class="row1" height="25">Percentage
Of
Questions:</td>
<td width="117" class="row1" height="25">Hard Level(%):</td>
<td width="140" class="row1" height="25">Medium Level(%):</td>
<td width="106" class="row1" height="25">Easy Level(%):</td>
<td width="233" class="row1" height="25">Select Subjects For Deletion</td>
</tr>
<%! int xx=1;%>
<%
int c=0;
String i=null;
i=((String)session.getAttribute("DUMMY"));
System.out.println("header = "+i);
if(i!=null)
{
if(i.compareTo("MAYANK")==0)
{
// for(c=0;c<xx;c++)
//{
%>
<tr>
<td width="122" height="25" class="row2">
<select name="sel_Subjects" size="1" >
<option selected>Select Subject</option>
<%
StringTokenizer st = new StringTokenizer(comboValues[1],"|");
while(st.hasMoreTokens())
{
String subject=st.nextToken();
%>
<option value="<%=subject%>"><%=subject%></option>
<%
System.out.println(" val of xx= "+xx);
}
System.out.println("val of i = "+i);
%>
</select>
</td>
<td width="204" height="25" class="row2">
<input type="text" name="textfield" size="10" >%
</td>
<td width="117" height="25" class="row2">
<input type="text" name="textfield1" size="11" ><input type="checkbox" name="checkbox1" value="checkbox">
</td>
<td width="140" height="25" class="row2">
<input type="text" name="textfield2" size="11" ><input type="checkbox" name="checkbox2" value="checkbox">
</td>
<td width="106" height="25" class="row2">
<input type="text" name="textfield3" size="11" ><input type="checkbox" name="checkbox3" value="checkbox">
</td>
<td width="233" height="25" class="row2">
<input type="checkbox" name="C1" value="ON">
</td>
</tr>
<%
//}
xx++;
}
}%>
</center>
<tr>
<td width="922" height="25" class="row1" colspan="6">
<p align="right"><input type="button" value="Delete Subjects" name="B4" onClick="delRow(document.all('myTableTBody'))">
<input type="button" value="Add More Subjects" name="B3" onclick="addRow(document.all('myTableTBody'))">
<input type="button" value="Finalize" onclick="modify_details()" >
<input type="button" value="Cancel" onclick="go_back()" ></td>
</tr>
</tbody>
</table>
</div>
</html:form>