Forums

checkbox option to table

raivis 15 Sep, 2010
Hello!

I have added checkbox option to my form.
Now I need to show results in table.

Which table data option ("varchar" or "tinyint" or any other) should I use to add the checkbox form results to table?

Thanks,
Raivis
GreyHead 15 Sep, 2010
Hi Raivis,

TINYINT if the value being returned is an integer. VARCHAR if it's a string. If in doubt use VARCHAR.

Bob

PS You need to refresh the DB Connection after any changes to database column names. In the Form Editor click the DB Connection tab and set the Connection to 'No'. Click the 'Apply icon in the toolbar to save the form, open the DB Connection tab, set the Connection back to 'Yes' and re-save the form. This will refresh the copy of the table information that ChronoForms uses.
raivis 15 Sep, 2010
Thanks Bob,

I'll check!

Brgds,
Raivis
raivis 15 Sep, 2010
Hi Bob,

Unfortunately I could not manage to get data into table..
Form contains two input fields: email and checkbox (with 3 options to choose to check).

Email is formed like text field and it works ok. Data (email address) gets into table.
Also email verification link function gets into table, with "1" or "0" data respectively.

But checkbox data dont. I have disabled and again enabled table connection as I always do.

What could be the issue?
AutoGenerated Code shows that the field name for checkbox option should be "check0" and I have added "check0" data field name with varchar option to table but it stays empty (with no any data).

If I check for the name field in FormCode html then I find it as "check0[]".

So I try to find the reason why there is no data for checkbox in table but can not so far..

Any suggestions?
Let me know if you would like to see codes..

Thanks,
Raivis
GreyHead 15 Sep, 2010
Hi Raivis,

If you use an array name (like check0[]) for the checkbox then set "ChronoForms handle my posted arrays" to 'Yes'

Bob
raivis 15 Sep, 2010
Hi Bob,

It was already set to "Yes".
By the way, if I try to add field name in table as check0[] the system does not allow to do it and says "alphanumeric characters or underscore"..

So I can not be sure if I should use "check0" as Autogenerated Code shows, or should I use "check0[]" as I find it FormCode (but system does not allow this option to be inserted into table).

I also have tried to use field names as check00 and check01 and check02 as there are three checkbox options in form. It also does not work..

Confused... Although tried to find it out myself very carefully...

Suggestions?
Brgds,
Raivis
raivis 16 Sep, 2010
Hi all,

Looks I found the problem.
I renamed the name fields in Form Code HTML so that they do not contain square brackets.
Now I am able to write correct name field into table (alphanumeric and underscore characters allowed only) and data gets into table.

Brgds,
Raivis
GreyHead 16 Sep, 2010
Hi Raivis,

If you have a group of checkboxes in your form you use the array name xxx[] (with square brackets) to link the results together. Then you use the same name without the square brackets in the table, template etc.

The ChronoForms array handler will manage the conversion from an array to a comma separated string for you if it is turned on.

If there's only a sinlge check-box then you don't need the array name.

Bob
bhabdi 30 Sep, 2010
I had the same problem as raivis had, and i fixed it as he said, removing the [] after the checkbox name,
gwells 26 Mar, 2011
I have a similar problem but, I'm unable to let Chronoforms handle the array (see thread http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=17888 where you were able to help me get the selected check box attachments to email in using the form resolved).

I've gone through the following threads to try various solutions but, unsuccessful so far.
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=19592&p=59793&hilit=check0+no+data#p59793
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=21199&p=66146&hilit=check0+no+data#p66146
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=12&t=21165&p=65921&hilit=check0+no+data#p65921

Thanks in advance!

p.s. Creating and editing the tables was a breeze using your book.
Dinosrules 05 Apr, 2011
Hello,

Maybe I am missing something here, but is there any way I can post CHECKBOX DATA into a table as 0 or 1?
If I use tinyint I always obtain a 0 into the database.

Can you please point some directions here?
Thank you!

DINO
GreyHead 06 Apr, 2011
Hi Dino,

I've not tried but I think that if your Checkbox values are 0 or 1 then they should save correctly.

BUT Checkboxes usually come in groups and return an array of results not just one so what is in the $_POST results from your form?

Bob
Dinosrules 06 Apr, 2011
Hi Bob,

Thank you for your reply and please accept my apologies for opening a new thread with the same problem.

Your idea was very good. I have used TyniInt as field type in the database, but If I use varchar and set the default value to 0 and each checkbox value as 1 then it's working.

I will just change all my field types to varchar.

Thank you again!
This topic is locked and no more replies can be posted.