i have a Struts jsp which creates a textbox dynamically using javascript.
function addRow_msgField()
{
var id =0;
var table = document.getElementById("msgfield");
var id = table.rows.length-1;
var newRow = document.all("msgfield").insertRow();
var oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name=alertFieldName"+id+" class='textBoxStyle' size='12' maxlength='50'/>";
oCell.style.verticalAlign = "top";
id++;
}
My table design is like this
<table align="center" id="msgfield" width="100%" cellpadding="1" cellspacing="0" border="1" bordercolorlight="#999999" bordercolordark="#FFFFFF" bordercolor="black">
<tr class="tableDataTextStyle">
<td width="15%">Field Name </td>
<td width="5%" align="center" onclick="addRow_msgField();">+</td>
</tr>
</table>
Say that three text box is created dynamically clicking the + sign.
<html:form action="/apialert" >
</html:form>
The FormBean for this action class is ApiAlertBean which contains
private String[] fieldname;
When i click submit button the values in each textbox should be set in the feilname array String of the FormBean.
I tried using <logic:iterate>
tag but could not acheive it since the no.of textboxes is dynamic (i.e it can be one or more )
Then i tried using hidden variable, i.e in js i append all the textbox values using deliminator (,) and then set the value to the hidden variable. i didnot succed in that also......