I have a problem with dynamically added fields.
In my form, people have the option to add lines to the form, which works perfectly.
The only problem is that chronoform doesn't e-mail or saves these newly created fields to me.
Is there something I am forgetting to place or function to call somewhere ?
Best wishes,
Lyzzy
-- HMTL code:
--javascript code
In my form, people have the option to add lines to the form, which works perfectly.
The only problem is that chronoform doesn't e-mail or saves these newly created fields to me.
Is there something I am forgetting to place or function to call somewhere ?
Best wishes,
Lyzzy
-- HMTL code:
</table>
<table align=center cellspacing = 5 >
<tbody id="tblBody">
<tr>
<td>Name</td>
<td>Position</td>
</TR>
<tr>
<td><input name="name_1" type="text" class="textfield" id="name_1" ></td>
<td><input name="pos_1" type="text" class="textfield" id="pos_1" ></td>
</TR>
</table>
<table align=center cellspacing = 5 >
<input name="count" type="hidden" id="count" value="1"/>
<TR>
<TD>
<input name="add" type="button" class="button" id="add" value="Add team member" onClick="addField();"/>
</td>
<TD></TD>
<td><input name="submit" value="Submit" type="submit"> </td>
</tr>
<TR>
</table>
--javascript code
function addField()
{
var tbody = document.getElementById("tblBody"«»);
var ctr = tbody.getElementsByTagName("input"«»).length + 1;
var inputName;
var inputPosition;
if ( ctr > (25+9)) //9 = inputfields for name, address and e-mail etc..
{
alert ("You are enthousiastic! Sign up as two separate teams, much more fun :«»-) "«»);
}
else
{
if (document.all){ //input.name doesn't work in IE
inputName= document.createElement('<input name="name_'+ctr+'">');
inputPosition= document.createElement('<input name="pos_'+ctr+'">');
}
else{
inputName= document.createElement('input');
inputName.name = "name_"+ctr;
inputPosition= document.createElement('input');
inputPosition.name = "pos_"+ctr;
}
inputName.id = inputName.name;
inputName.type = "text";
inputName.value = "";
inputName.className = "textfield";
inputPosition.id = inputPosition.name;
inputPosition.type = "text";
inputPosition.value = "";
inputPosition.className = "textfield";
var cell_1 = document.createElement('td');
cell_1.appendChild(inputName);
var cell_2= document.createElement('td');
cell_2.appendChild(inputPosition);
var row = document.createElement('tr');
row.appendChild(cell_1);
row.appendChild(cell_2);
tbody.appendChild(row);
window.document.the_form.count.value = ctr;
}
}