Dynamic form processing in struts
Hi all,
I need your help regarding dynamic form elements form processing.
Here is my JSP Script,
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html:html>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<TITLE>Processing Dynamic Forms</TITLE>
<script type="text/javascript">
//function which adds new row
function AddRow()
{
tb=document.getElementById("demo");
// attach counter
lnrows = tb.rows.length;
//alert(lnrows);
newrow = tb.insertRow(lnrows);
var fourth_col ="amt"+lnrows;
cell3=newrow.insertCell(0);
cell3.innerHTML="<center><input type='text' id='"+fourth_col+"' name='"+fourth_col+"' size='10'/></center>";
document.getElementById("cntr").value = lnrows;
}
// function to delete row
function DeleteRow()
{
tb=document.getElementById("demo");
lnrows = tb.rows.length;
//alert(lnrows);
if(lnrows > 2)
{
tb.deleteRow(lnrows-1);
document.getElementById("cntr").value = tb.rows.length - 1;
}
}
</script>
</HEAD>
<BODY>
<html:form action="/dynaActions">
<TABLE id='demo' align='center' width='80%' border='1'>
<TR>
<TH width='25%'>Party Name</TH>
</TR>
<TR>
<TD align='center'><input type='text' id="party1" name="party1" size="30" /></TD>
</TR>
</TABLE>
<TABLE align='center' width='80%' border='0'>
<TR align="right">
<td>
<html:button property="Add" value="Add" onclick="AddRow();" ></html:button>
<html:button property="Remove" value="Remove" onclick="DeleteRow();"></html:button>
</td>
</TR>
<TR align="center">
<td>
<input type='hidden' id="cntr" name="cntr" value="1" />
<html:submit/>
</td>
</TR>
</TABLE>
</html:form>
</BODY>
</html:html>
As you seen there is dynamically form elements generated as many as required. Now how do I process this with ActionForm & Action?
Regards,
Mahesh

