but the problem is... if i select multiple answer, only the last answer record at the table.
please help.
thanks.
[file name=check.txt size=1147]http://www.chronoengine.com/components/com_fireboard/uploaded/files/check.txt[/file]


suckerhead wrote:you meant i have to name all the check box music[]?
<?php
if ( is_array($_POST[field_name]) ) {
$_POST[field_name] = implode(',', $_POST[field_name]);
}
?>$name = preg_replace('/name=("|\')/', '', $new_match2);
$name = str_replace('[]', '', $name); /* <- insert this line */
$emailbodytemplate = $rows[0]->emailtemplate;GreyHead wrote:Hi suckerhead,
Yes, that's good for the 'name' attributes (technically the 'id' attributes don't need the brackets and they should all be unique e.g. id='music_jazz' or id='music_1' but it probably won't make any real difference unless you use the ids in css or javascript).
I think that you now need to make some code hacks to have array fields work properly in ChronoForms v2.1:
In the Form Code tab paste in the 'On Submit code - before sending email:' box.
- Code: Select all
<?php
if ( is_array($_POST[field_name]) ) {
$_POST[field_name] = implode(',', $_POST[field_name]);
}
?>
If you use templates, then to get them to work correctly open up chronocontact.php and go to line 143 and insert a new line after it .
- Code: Select all
$name = preg_replace('/name=("|\')/', '', $new_match2);
$name = str_replace('[]', '', $name); /* <- insert this line */
$emailbodytemplate = $rows[0]->emailtemplate;
Bob<br><br>Post edited by: GreyHead, at: 2007/06/25 15:21
<?php
if ( is_array($_POST[music]) ) {
$_POST[music] = implode(',', $_POST[music]);
}
?>What kind of music do you listen?(can multiple select) <br />
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input name="music" type="checkbox" value="jazz" />
Jazz</td>
<td><input name="music" type="checkbox" value="rock" />
Rock</td>
<td><input name="music" type="checkbox" value="pop" />
Pop</td>
</tr>
<tr>
<td><input name="music" type="checkbox" value="Rap" />
Rap</td>
<td><input name="music" type="checkbox" value="hiphop" />
Hip Hop </td>
<td><input name="music" type="checkbox" value="classic" />
Classical</td>
</tr>
<tr>
<td><input name="music" type="checkbox" value="instrumental" />
Instrumental</td>
<td><input name="music" type="checkbox" value="Heavy Metal" />
Heavy Metal </td>
<td><input name="music" type="checkbox" value="ballad" />
Ballad</td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit" />
</p><td><input name="music[]" type="checkbox" value="jazz" />Jazz</td>$_POST[$name] = str_replace('[]','',$_POST[$name]);
if ( is_array($_POST[$name]) ) {
$_POST[$name] = implode(',', $_POST[$name]);
}
What kind of music do you listen?(can multiple select) <br />
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input name="music[]" type="checkbox" value="jazz" />
Jazz</td>
<td><input name="music[]" type="checkbox" value="rock" />
Rock</td>
<td><input name="music[]" type="checkbox" value="pop" />
Pop</td>
</tr>
<tr>
<td><input name="music[]" type="checkbox" value="Rap" />
Rap</td>
<td><input name="music[]" type="checkbox" value="hiphop" />
Hip Hop </td>
<td><input name="music[]" type="checkbox" value="classic" />
Classical</td>
</tr>
<tr>
<td><input name="music[]" type="checkbox" value="instrumental" />
Instrumental</td>
<td><input name="music[]" type="checkbox" value="Heavy Metal" />
Heavy Metal </td>
<td><input name="music[]" type="checkbox" value="ballad" />
Ballad</td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
<?php
if ( is_array($_POST[music]) ) {
$_POST[music] = implode(',', $_POST[music]);
}
?>
admin wrote:Did you try my solution above ?
Max

Return to ChronoForms Questions & Answers
Users browsing this forum: MSN [Bot] and 3 guests