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]

please try this and let me know the effect on the email results and the database record
Cheers
max
you meant i have to name all the check box music[]?
still error
if i sellect jazz, rock and ballad, i want the result on the database (table music) is jazz, rock, ballad
please see attached my file?
can you please edit for me? [file name=check-9e339f1a8c887e6e42ab798963237fe4.txt size=1112]http://www.chronoengine.com/components/com_fireboard/uploaded/files/check-9e339f1a8c887e6e42ab798963237fe4.txt[/file]
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.
<?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 .
$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
Cheers
Max
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.
<?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 .
$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
Hi Bob and Max,
thanks for your reply,
Right now i'm using version 2.0, and have another form running. is it ok for the current running form if i just uninstall and install the new version, or i have to backup the form code?
sorry i'm asking to much, cos i dont have knownledge in php.
correct me if i'm wrong,
i have to use version 2.1 and
i use 'name' attribute with 'fieldname[]' and put the code you give on the submit code.
how about templates? what is that?
is it better to put code on the template or put code on submit code
please info.
thanks
Bob,
still can't.
here's my step
first,
put the php code on submit code before sending email
the code like this :
<?php
if ( is_array($_POST[music]) ) {
$_POST[music] = implode(',', $_POST[music]);
}
?>
second,
change (input more code) the chronocontact.php line 143
and third,
my html form code like this
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>
may be i'm misunderstand or not understand your guide?
can you make corection file (which code should i use on form tag or on submit code) for my form like that above and upload the file for me?
thanks again.
The first problem is that you've taken the '[]'s out of the name attributes again. You do need these; they allow the form to pass an array of values with all the results instead of just a single value for the last checkbox. The other fixes are to let ChronoForms handle the array.
So your entries need to be like this:
<td><input name="music[]" type="checkbox" value="jazz" />Jazz</td>
Bob
The solution is :
#1- u must use music[] for all ur checkboxes names
#2- hack chronocontact.php by adding these lines :
$_POST[$name] = str_replace('[]','',$_POST[$name]);
if ( is_array($_POST[$name]) ) {
$_POST[$name] = implode(',', $_POST[$name]);
}
"UNDER" these lines :
#129
#144
#179
i'm using chrono engine version 2.1 and joomla 10.0.12 now
still not working (sorry..) after follow your instruction
please info me which one is wrong, with this step
#1 hack the chronocontact.php (file attached) <<< can you check the file please😟
#2 make new form, i put back the []'s on all names
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>
#3 put this code on submit code (before sending emails)
<?php
if ( is_array($_POST[music]) ) {
$_POST[music] = implode(',', $_POST[music]);
}
?>
#4 save the form
#5 create table
>>>> the colom name for the music music[] << is it correct?
and when i press create table, appear windows pop up "Query was Empty SQL="
that's my last step.. so it did not create table on database.
until this step,
please info me is there something i miss or something wrong with the code (form code and chrono_hack.php)
Max
When I have a few minutes I'll create a full working example of this and make sure that it all works together. hHopefully later this evening.
Bob
Did you try my solution above ?
Max
I did,Max. the last post i forget to attached the file
here's i attached the file.
If there are a question like this (jpg attached)? how it would be?
[file name=chrono_hack.zip size=3049]http://www.chronoengine.com/components/com_fireboard/uploaded/files/chrono_hack.zip[/file]

How does the email looks like after applying my hack ?
I dont need the output in email, i need it as a database table.
After I try all suggestion from you and Bob, i still cannot solve the problem.😟😟
still waiting for solution, cos i dont have knowledge in programming.
but thanks for the great support and extention.
please find me solution for this kind of problem..;)
:P
All my hacks was based on that I understood we need this to appear on the email, for the database you should use Bob's solution!
so, please follow these steps :
#1- get fresh unhacked V2.1 version
#2- have your code with music[] as the field name for ur checkboxes
#3- create table, whil you are choosing the fields, check only 1 music field and make it LONGTEXT
#4- at teh autogenerated tab, at the top of the code after <?php, put this :
<?php
if ( is_array($_POST[music]) ) {
$_POST[music] = implode(',', $_POST[music]);
}
?>
now if you find $_POST['music[]'] at teh code below please make it just $_POST['music']
Now it should work! Please let us know
Max
I think I have this working smoothly (fingers crossed). There are several places where you need to deal with the array that is returned by checkbox inputs. The changes are pretty simple and are along the lines described here but rather than try and explain them I've attached a couple of modified files for ChronoForms 2.1.4 - chronocontact.php and admin.chronocontact.php Make sure that you have copies of the distribution files then overwrite your installation with these two.
These files should fix the following problems:
+ Checkbox inputs only show the final entry
+ Field name shown as 'name[]' on Create table
+ Incomplete SQL error on Create table
+ Show checkbox arrays as comma separated lists in e-mails and database tables.
Please let me know if you have any problems and I'll look again - sorry this has taken so long, it's been a busy week.
Bob
[file name=chronocontact_checkbox.zip size=6927]http://www.chronoengine.com/components/com_fireboard/uploaded/files/chronocontact_checkbox.zip[/file]
Hi Suckerhead,
I think I have this working smoothly (fingers crossed). There are several places where you need to deal with the array that is returned by checkbox inputs. The changes are pretty simple and are along the lines described here but rather than try and explain them I've attached a couple of modified files for ChronoForms 2.1.4 - chronocontact.php and admin.chronocontact.php Make sure that you have copies of the distribution files then overwrite your installation with these two.
These files should fix the following problems:
+ Checkbox inputs only show the final entry
+ Field name shown as 'name[]' on Create table
+ Incomplete SQL error on Create table
+ Show checkbox arrays as comma separated lists in e-mails and database tables.
Please let me know if you have any problems and I'll look again - sorry this has taken so long, it's been a busy week.
Bob
[file name=chronocontact_checkbox.zip size=6927]http://www.chronoengine.com/components/com_fireboard/uploaded/files/chronocontact_checkbox.zip[/file]
Hi bob,
thanks for what you have done
but still not working in here after i replace the admin.chronocontact.php and chronocontact.php.
here's my step (correct me if i'm wrong)
#1 create table, and add '[]' on the checkbox, eg: name"abc[]"
#2a create table--- success
b try the form --- the result on the database is "Array" not the value.
#3a add code onsubmit - beforesending email
<?php
if ( is_array($_POST[abc]) ) {
$_POST[abc] = implode(',', $_POST[abc]);
}
?>
#3b try the form - same result.
can you give me more detail.
- sample form
- code to put on the onsubmit code before sending
- or i miss something to put on?
thanks again
Ah! I may have found it - please test with 'E-mail the results' set to 'Yes' (I know you don't want to do this but that's the one difference between my form and yours).
Also leave out the code in #3a below as that should already be in the amended files.
If this works then I'll make a change to the files so that it works with or without the e-mail option.
Bob
Hi Suckerhead,
Ah! I may have found it - please test with 'E-mail the results' set to 'Yes' (I know you don't want to do this but that's the one difference between my form and yours).
Also leave out the code in #3a below as that should already be in the amended files.
If this works then I'll make a change to the files so that it works with or without the e-mail option.
Bob
Bob,
you're my man.... Finally it works.. you're awesome man...
I'm waiting your correction file so it works with or without email option. (please attach the file😛 )
Thanks bro..
Try this version. Both files are included in case anyone else tries it but only chronocontact.php is changed from the previous version.
This should work with any single dimension array in a form - that's what you are using. However, it won't work for multiple dimension arrays e.g. if you name all your form fields "form['some_name']" and among them have some checkboxes with names like "form['some_array[]']" That would need a further mod.
Forms like this are pretty rare - but sometimes it can be convenient to sweep up form values in an array for further processing.
Bob [file name=chronocontact_checkbox-cf27fcaa41b8fe861c763c88700b3d5a.zip size=6992]http://www.chronoengine.com/components/com_fireboard/uploaded/files/chronocontact_checkbox-cf27fcaa41b8fe861c763c88700b3d5a.zip[/file]<br><br>Post edited by: GreyHead, at: 2007/06/29 16:02
Hi suckerhead,
Try this version. Both files are included in case anyone else tries it but only chronocontact.php is changed from the previous version.
This should work with any single dimension array in a form - that's what you are using. However, it won't work for multiple dimension arrays e.g. if you name all your form fields "form['some_name']" and among them have some checkboxes with names like "form['some_array[]']" That would need a further mod.
Forms like this are pretty rare - but sometimes it can be convenient to sweep up form values in an array for further processing.
Bob [file name=chronocontact_checkbox-cf27fcaa41b8fe861c763c88700b3d5a.zip size=6992]http://www.chronoengine.com/components/com_fireboard/uploaded/files/chronocontact_checkbox-cf27fcaa41b8fe861c763c88700b3d5a.zip[/file]<br><br>Post edited by: GreyHead, at: 2007/06/29 16:02
HUURAAAYYY......
Problem solved...
thanks Bob for the support
and thanks to the great extention ....
please include this on the next update version...
thanks again,
I'm having difficulty with only the last checkbox (sharing names with others) being submitted ...so I tried these files, but it causes an error on my site ...the form doesn't display at all. I'm assuming that it's because the version of chronoforms has changed since these files were created. I'm using version: 2.5 J1.5 RC3.1
Any thoughts?
Thanks,
nick.
I doubt this has to do with any changes in ChronoForms. Please copy and paste the checkbox part of your form code here and I'll take a look.
Bob
Code is as follows (chopped up):
<script type="text/javascript">
function checkboxlimit(checkgroup, limit){
var checkgroup=checkgroup
var limit=limit
for (var i=0; i<checkgroup.length; i++){
checkgroup[i].onclick=function(){
var checkedcount=0
for (var i=0; i<checkgroup.length; i++)
checkedcount+=(checkgroup[i].checked)? 1 : 0
if (checkedcount>limit){
alert("You can only select a maximum of "+limit+" items")
this.checked=false
}
}
}
}
</script>
......
<tr>
<td valign="top"><p><strong>5. Where do you meet singles</strong></p>
<p>Choose your top three</p></td>
<td valign="top"><input type="checkbox" name="Q5" value="Pubs & Clubs"/>
Pubs & Clubs<br />
<input type="checkbox" name="Q5" value="Online Dating"/>
Online Dating<br />
<input type="checkbox" name="Q5" value="Speed Dating"/>
Speed Dating<br />
<input type="checkbox" name="Q5" value="Social Clubs"/>
Social Clubs<br />
<input type="checkbox" name="Q5" value="Blind Dates"/>
Blind Dates<br />
<input type="checkbox" name="Q5" value="Friends Parties"/>
Friends Parties<br />
<input type="checkbox" name="Q5" value="Mobile Dating"/>
Mobile Dating<br />
<input type="checkbox" name="Q5" value="Sports Clubs/Salsa Nights"/>
Sports Clubs/Salsa Nights<br />
<input type="checkbox" name="Q5" value="Singles party"/>
Singles party<br />
<input type="checkbox" name="Q5" value="Facebook or MySpace"/>
Facebook or MySpace<br />
<br /> </td>
</tr>
<tr>
......
<script type="text/javascript">
checkboxlimit(document.ChronoContact_whatsingleswant.Q5, 3)
</script>
Any help would be appreciated!
Thanks🙂
you will need to name your checkboxes Q5[]
Cheers
Max
I've done that, and it is now working - but doing that then stops the 'maximum of 3 choices' code from working...
Do you have any suggestions of why that might happen?
Thanks so much, very helpful forums here🙂
Try to edit this line too :
checkboxlimit(document.ChronoContact_whatsingleswant.Q5, 3)
Q5[]
Cheers
Max