I cant seem to get some of the data to send to my email i also plan on using the db_save action and export_csv as well
Link to form:
http://www.halfmoonfire.org/index.php?option=com_chronoforms&chronoform=KidsChristmasParty
Link to form:
http://www.halfmoonfire.org/index.php?option=com_chronoforms&chronoform=KidsChristmasParty
Hi fisher12188,
I can see a couple of problems:
a) the input name 'childs name' has a space in it which isn't valid HTML. Please change it to say 'childs_name'
b) the Add one inputs all have the same names so you only get the last one submitted. You can either switch them to array names e.g. 'childs_name[]' or make them distinct e.g. 'childs_name_1'. Which is better depends on how you plan to handle the results.
Bob
I can see a couple of problems:
a) the input name 'childs name' has a space in it which isn't valid HTML. Please change it to say 'childs_name'
b) the Add one inputs all have the same names so you only get the last one submitted. You can either switch them to array names e.g. 'childs_name[]' or make them distinct e.g. 'childs_name_1'. Which is better depends on how you plan to handle the results.
Bob
b) the Add one inputs all have the same names so you only get the last one submitted. You can either switch them to array names e.g. 'childs_name[]' or make them distinct e.g. 'childs_name_1'. Which is better depends on how you plan to handle the results.
Bob, i cant seem to find the add one inputs you are talking about
Hi fisher12888,
Bob
<div class="show_me" id="recipient_1">
<div class="multiline_start">
<label>Child's Name</label>
<input type="text" id="childs_name" name="childs_name" size="30" maxlength="150">
</div>
<div class="multiline_add">
<label>Age</label>
<input type="text" id="age" name="age" size="10" maxlength="10">
</div>
<div id="gender_container_div" class=" cfdiv_select multiline_add"><label>Gender</label><select name="gender" size="1">
<option value=""></option>
<option value="Boy">Boy</option>
<option value="Girl">Girl</option>
</select>
</div>
<div class="clear"></div>
<div><input type="button" class="add_one" value="Add Child" id="addone_2" name="addone_2" style="display: none;"></div>
</div>
Bob
Thanks bob for the code, but i am unsure where i am putting it exactly
Hi fisher12188,
You may already have it somewhere - it's copied from the form page you linked to.
Bob
You may already have it somewhere - it's copied from the form page you linked to.
Bob
Okay, then i guess im not comprehending your suggestion correctly then, can you give me some more insight? This is the first time ive tried using a custom element on a form so i guess its confusing to me.
Hi fisher12888,
Please tell me exactly what code you have got in the Custom Element element and Load JS actions.
Bob
Please tell me exactly what code you have got in the Custom Element element and Load JS actions.
Bob
Custom Element
On Load (load js)
For the load js i have the dynamic file to no. You can also email me at [email]adam@creativevisionzit.com[/email] if needed.
<?php
// set the total count
$count = 5;
for ( $i = 1; $i <= $count; $i++ ) {
// add classes which will let us identify the inputs to hide
if ( $i == 1 ) {
$class = 'show_me';
} else {
$class = 'hide_me';
}
// add the 'Add one' buttons (but not to the last set)
if ( $i < $count ) {
$j = $i+1;
$button = "<div><input type='button' name='addone_[]' id='addone_[]' value='Add Child' class='add_one' /></div>";
} else {
$button = "";
}
// add the inputs with a little ChronoForms styling
echo "<div id='recipient_{$i}' class='{$class}' >
<div class='multiline_start'>
<label>Child's Name</label>
<input maxlength='150' size='30' type='text' name='childs_name' id='childs_name' />
</div>
<div class='multiline_add'>
<label>Age</label>
<input maxlength='10' size='10' type='text' name='age' id='age' />
</div>
<div class=' cfdiv_select multiline_add' id='gender_container_div'><label>Gender</label><select size='1' name='gender'>
<option value=''></option>
<option value='Boy'>Boy</option>
<option value='Girl'>Girl</option>
</select>
</div>
<div class='clear' ></div>
{$button}
</div>";
}
?>
On Load (load js)
window.addEvent('domready', function() {
// hide all but the first set
$$('div.hide_me').each(function(el) {
el.setStyle('display', 'none');
});
// call the addOne function passing the row number
$$('input.add_one').each(function(el) {
el.addEvent('click', function(event) {
var id = event.target.id.substr(7, 1);
addOne(id);
});
});
});
// display the next row and hide the last 'Add one' button
function addOne(id) {
$('addone_'+id).setStyle('display', 'none');
$('recipient_'+id).setStyle('display', 'block');
};
For the load js i have the dynamic file to no. You can also email me at [email]adam@creativevisionzit.com[/email] if needed.
Yes it does, but im still confused as to what im suppose to do. This is what the form looks like now: http://www.halfmoonfire.org/index.php?option=com_chronoforms&chronoform=KidsChristmasParty it seems like the array isnt working when the email is sent or for the db_save.
custom element
Load js
email[gh]
under the handle arrays function i have nothing, not sure if i need to put something there or if i even need the function
custom element
<?php
// set the total count
$count = 5;
for ( $i = 1; $i <= $count; $i++ ) {
// add classes which will let us identify the inputs to hide
if ( $i == 1 ) {
$class = 'show_me';
} else {
$class = 'hide_me';
}
// add the 'Add one' buttons (but not to the last set)
if ( $i < $count ) {
$j = $i+1;
$button = "<div><input type='button' name='addone_{$i}' id='addone_{$i}' value='Add Child' class='add_one' /></div>";
} else {
$button = "";
}
// add the inputs with a little ChronoForms styling
echo "<div id='recipient_{$i}' class='{$class}' >
<div class='multiline_start'>
<label>Child's Name</label>
<input maxlength='150' size='30' type='text' name='childs_name' id='childs_name_{$i}' />
</div>
<div class='multiline_add'>
<label>Age</label>
<input maxlength='10' size='10' type='text' name='age' id='age_{$i}' />
</div>
<div class=' cfdiv_select multiline_add' id='gender_{$i}'><label>Gender</label><select size='1' name='gender'>
<option value=''></option>
<option value='Boy'>Boy</option>
<option value='Girl'>Girl</option>
</select>
</div>
<div class='clear' ></div>
{$button}
</div>";
}
?>
Load js
window.addEvent('domready', function() {
// hide all but the first set
$$('div.hide_me').each(function(el) {
el.setStyle('display', 'none');
});
// call the addOne function passing the row number
$$('input.add_one').each(function(el) {
el.addEvent('click', function(event) {
var id = event.target.id.substr(7, 1);
addOne(id);
});
});
});
// display the next row and hide the last 'Add one' button
function addOne(id) {
$('addone_'+id).setStyle('display', 'none');
$('recipient_'+id).setStyle('display', 'block');
};
email[gh]
<table cellpadding="5" cellspacing="5" border="0">
<tr>
<td>
<strong>Parent/Guardian Name</strong>
</td>
<td>
{parent_name}
</td>
</tr>
<tr>
<td>
<strong># of Adults</strong>
</td>
<td>
{number_of_adults}
</td>
</tr>
<tr>
<td>
<strong>Email</strong>
</td>
<td>
{email}
</td>
</tr>
<tr>
<td>
<strong>Address</strong>
</td>
<td>
{address}
</td>
</tr>
<tr>
<td colspan='2'>
<?php
// set the total count
$count = 5;
for ( $i = 1; $i <= $count; $i++ ) {
// add classes which will let us identify the inputs to hide
if ( $i == 1 ) {
$class = 'show_me';
} else {
$class = 'hide_me';
}
// add the 'Add one' buttons (but not to the last set)
if ( $i < $count ) {
$j = $i+1;
$button = "<div></div>";
} else {
$button = "";
}
// add the inputs with a little ChronoForms styling
echo "<div id='recipient_{$i}' class='{$class}' >
<div class='multiline_start'>
<label>Child's Name</label>
{childs_name_$i}
</div>
<div class='multiline_add'>
<label>Age</label>
{age_$i}
</div>
<div class=' cfdiv_select multiline_add' id='gender.'><label>Gender</label>
{gender_$i}
</div>
<div class='clear' ></div>
{$button}
</div>";
}
?>
</td>
</tr>
</table>
under the handle arrays function i have nothing, not sure if i need to put something there or if i even need the function
Hi fisher12188,
Back to my original suggestion. Try replacing the input names with either array names
Bob
Back to my original suggestion. Try replacing the input names with either array names
<div class='multiline_start'>
<label>Child's Name</label>
<input maxlength='150' size='30' type='text' name='childs_name[]' id='childs_name_{$i}' />
</div>
<div class='multiline_add'>
<label>Age</label>
<input maxlength='10' size='10' type='text' name='age[]' id='age_{$i}' />
</div>
<div class=' cfdiv_select multiline_add' id='gender_{$i}'><label>Gender</label><select size='1' name='gender[]'>
<option value=''></option>
<option value='Boy'>Boy</option>
<option value='Girl'>Girl</option>
</select>
</div>
<div class='clear' ></div>
{$button}
</div>";
or add identifiers to them<div class='multiline_start'>
<label>Child's Name</label>
<input maxlength='150' size='30' type='text' name='childs_name_{$i}' id='childs_name_{$i}' />
</div>
<div class='multiline_add'>
<label>Age</label>
<input maxlength='10' size='10' type='text' name='age_{$i}' id='age_{$i}' />
</div>
<div class=' cfdiv_select multiline_add' id='gender_{$i}'><label>Gender</label><select size='1' name='gender_{$i}'>
<option value=''></option>
<option value='Boy'>Boy</option>
<option value='Girl'>Girl</option>
</select>
</div>
<div class='clear' ></div>
{$button}
</div>";
Bob
or add identifiers to them
<div class='multiline_start'>
<label>Child's Name</label>
<input maxlength='150' size='30' type='text' name='childs_name_{$i}' id='childs_name_{$i}' />
</div>
<div class='multiline_add'>
<label>Age</label>
<input maxlength='10' size='10' type='text' name='age_{$i}' id='age_{$i}' />
</div>
<div class=' cfdiv_select multiline_add' id='gender_{$i}'><label>Gender</label><select size='1' name='gender_{$i}'>
<option value=''></option>
<option value='Boy'>Boy</option>
<option value='Girl'>Girl</option>
</select>
</div>
<div class='clear' ></div>
{$button}
</div>";
I used this one and the email now works, but the db_save is not working and when i go into to create a new table i get this
Field name "addone_{$j}" is invalid, please fix the field name in the wizard (or the form code) then retry again.
Field name "childs_name_{$i}" is invalid, please fix the field name in the wizard (or the form code) then retry again.
Field name "age_{$i}" is invalid, please fix the field name in the wizard (or the form code) then retry again.
Field name "gender_{$i}" is invalid, please fix the field name in the wizard (or the form code) then retry again.
Any ideas?
Hi fisher12188,
It depends on how you want to save the information - which in turn depends on what you need to do with it. You can add fifteen columns to the table; condense all the data into one column or use two linked tables, one for the main information and the second for the repeated values.
Bob
Bob
It depends on how you want to save the information - which in turn depends on what you need to do with it. You can add fifteen columns to the table; condense all the data into one column or use two linked tables, one for the main information and the second for the repeated values.
Bob
Bob
I need it so it can be processed into a csv file without issue. Whats the best option?
Hi fisher12188,
Probably fifteen columns; you can add them by hand in the Create Table dialogue.
Bob
Probably fifteen columns; you can add them by hand in the Create Table dialogue.
Bob
like child_name_1, age_1, gender_1, child_name_2......
in that fashion?
in that fashion?
This topic is locked and no more replies can be posted.