ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

e-mail dynamically added fields

lizzy81 19 Nov, 2007
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:

</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;
}
}
GreyHead 19 Nov, 2007
Hi Lyzzy,

ChronoForms parses the html from the HTML code field to create a list of fields that it handles. The dynamically created fields aren't there so they aren't parsed or handled.

The only simple fix I can think of is to make sure that your dynamic fields return arrays and to put the array names in the form html, maybe as hidden fields. I think that this *should* work but not tested and no promises.

Bob
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com