ChronoEngine Forums
Welcome, Guest
Please Login or Register.    Lost Password?
multiple checkbox , only record last answer? (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: multiple checkbox , only record last answer?
#763
suckerhead (User)
Junior Boarder
Posts: 22
graphgraph
User Offline Click here to see the profile of this user
Re:multiple checkbox , only record last answer? 1 Year ago Karma: 1  
GreyHead wrote:
QUOTE:
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:

<?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:

$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 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
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#765
suckerhead (User)
Junior Boarder
Posts: 22
graphgraph
User Offline Click here to see the profile of this user
Re:multiple checkbox , only record last answer? 1 Year ago Karma: 1  


Bob,
still can't.
here's my step

first,
put the php code on submit code before sending email

the code like this :
Code:

&lt;?php if ( is_array($_POST[music]) ) { $_POST[music] = implode(',', $_POST[music]); } ?&gt;
second, change (input more code) the chronocontact.php line 143 and third, my html form code like this
Code:

What kind of music do you listen?(can multiple select) &lt;br /&gt; &lt;table width=&quot;400&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt; &lt;tr&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;jazz&quot; /&gt; Jazz&lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;rock&quot; /&gt; Rock&lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;pop&quot; /&gt; Pop&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;Rap&quot; /&gt; Rap&lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;hiphop&quot; /&gt; Hip Hop &lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;classic&quot; /&gt; Classical&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;instrumental&quot; /&gt; Instrumental&lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;Heavy Metal&quot; /&gt; Heavy Metal &lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music&quot; type=&quot;checkbox&quot; value=&quot;ballad&quot; /&gt; Ballad&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt; &lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; /&gt; &lt;/p&gt;
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.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#766
GreyHead (Admin)
Support
Admin
Posts: 2902
graph
User Offline Click here to see the profile of this user
Gender: Male bobjanes Location: Brittany
Re:multiple checkbox , only record last answer? 1 Year ago Karma: 62  
Hi suckerhead,

The first problem is that you've taken the '[]&#039;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:[code]&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkboi suckerhead,

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:
Code:

&lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;jazz&quot; /&gt;Jazz&lt;/td&gt;
Bob
 
Report to moderator   Logged Logged  
 
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
  The administrator has disabled public write access.
#772
admin (Admin)
Admin
Posts: 1631
graphgraph
User Online Now Click here to see the profile of this user
Re:multiple checkbox , only record last answer? 1 Year ago Karma: 23  
Hi,

The solution is :

#1- u must use music[] for all ur checkboxes names
#2- hack chronocontact.php by adding these lines :
[code]
$_POST[$name] = str_replace(&#039;[]&#039;,&#039;&#039;,$_POST[$name]);
if ( is_array($_POST[$name]) ) {
$_POST[$name] = implode(&#039;,&#039;, $_POST[$name]);
}
[/code]

&amp;qi,

The solution is :

#1- u must use music[] for all ur checkboxes names
#2- hack chronocontact.php by adding these lines :
Code:

$_POST[$name] = str_replace('[]','',$_POST[$name]); if ( is_array($_POST[$name]) ) { $_POST[$name] = implode(',', $_POST[$name]); }
&quot;UNDER&quot; these lines : #129 #144 #179
 
Report to moderator   Logged Logged  
 
ChronoForms Developer Thanks for using ChronoForms.
If you have any problems with ChronoForms please tell us.
If you like ChronoForms please post a review at Joomla.org
  The administrator has disabled public write access.
#778
suckerhead (User)
Junior Boarder
Posts: 22
graphgraph
User Offline Click here to see the profile of this user
Re:multiple checkbox , only record last answer? 1 Year ago Karma: 1  
Hi Guys,

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) &lt;&lt;&lt; can you check the file please

#2 make new form, i put back the []&#039;s on all names
[code]
What kind of music do you listen?(can multiple select) &amp;lt;br /&amp;gt;

&amp;lt;table width=&amp;quot;400&amp;quot; border=&amp;quot;0&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot;&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;jazz&amp;quot; /&amp;gt;
Jazz&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;rock&amp;quot; /&amp;gt;
Rock&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;pop&amp;quot; /&amp;gt;
Pop&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;Rap&amp;quot; /&amp;gt;
Rap&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;hiphop&amp;quot; /&amp;gt;
Hip Hop &amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;classic&amp;quot; /&amp;gt;
Classical&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;instrumental&amp;quot; /&amp;gt;
Instrumental&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;Heavy Metal&amp;quot; /&amp;gt;
Heavy Metal &amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;input name=&amp;quot;music[]&amp;quot; type=&amp;quot;checkbox&amp;quot; value=&amp;quot;ballad&amp;quot; /&amp;gt;
Ballad&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;

&amp;lt;p&amp;gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; name=&amp;quot;Submit&amp;quot; value=&amp;quot;Submit&amp;quot; /&amp;gt;
&amp;lt;/p&amp;gt;
[/code]

#3 put this code on submit code (before sending emails)
[code] &amp;lt;?php
if ( is_array($_POST[music]) ) {
$_POST[music] = implode(&#039;,&#039;, $_POST[music]);
}
?&amp;gt;
[/code]

#4 save the form
#5 create table
&amp;gt;&amp;gt;&amp;gt;&amp;gt; the colom name for the musi Guys,

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) &lt;&lt;&lt; can you check the file please

#2 make new form, i put back the []'s on all names
Code:

What kind of music do you listen?(can multiple select) &lt;br /&gt; &lt;table width=&quot;400&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt; &lt;tr&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;jazz&quot; /&gt; Jazz&lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;rock&quot; /&gt; Rock&lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;pop&quot; /&gt; Pop&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;Rap&quot; /&gt; Rap&lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;hiphop&quot; /&gt; Hip Hop &lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;classic&quot; /&gt; Classical&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;instrumental&quot; /&gt; Instrumental&lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;Heavy Metal&quot; /&gt; Heavy Metal &lt;/td&gt; &lt;td&gt;&lt;input name=&quot;music[]&quot; type=&quot;checkbox&quot; value=&quot;ballad&quot; /&gt; Ballad&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt; &lt;input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot; /&gt; &lt;/p&gt;
#3 put this code on submit code (before sending emails)
Code:

&lt;?php if ( is_array($_POST[music]) ) { $_POST[music] = implode(',', $_POST[music]); } ?&gt;
#4 save the form #5 create table &gt;&gt;&gt;&gt; the colom name for the music music[] &amp;lt;&amp;lt; is it correct? and whe><hr /><code class="php"> &amp;lt;?php if ( is_array($_POST[music]) ) { $_POST[music] = implode(&#039;,&#039;, $_POST[music]); } ?&amp;gt; </code><hr /></td></tr></table> #4 save the form #5 create table &gt;&gt;&gt;&gt; the colom name for the music music[] &lt;&lt; is it correct? and when i press create table, appear windows pop up &quot;Query was Empty SQL=&quot; 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)
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#781
admin (Admin)
Admin
Posts: 1631
graphgraph
User Online Now Click here to see the profile of this user
Re:multiple checkbox , only record last answer? 1 Year ago Karma: 23  
Did you try my solution above ?

Max
 
Report to moderator   Logged Logged  
 
ChronoForms Developer Thanks for using ChronoForms.
If you have any problems with ChronoForms please tell us.
If you like ChronoForms please post a review at Joomla.org
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop


equalheight If you have any questions you can post to our forums and we will be glad to help ASAP

Members Login






Lost Password?
No account yet? Register

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

ChronoForms License

equalheightTo be able to continue working at this component we decided to get a small profit out of it but at the same time don't force everybody to pay in order to use this great component.

 

 From version 1.5 and up a link at the bottom of everyform created will be placed, saying "joomla professional work", the link will be to us here htttp://www.chronoengine.com, its illegal to remove this link from the source code unless you have a license,

so the license is very simply for the same ChronoForms component without a link, thats all!

This License is for 5 different websites ONLY. 

 

 However, in order to allow everybody to still use the component and even get out of this, the link is inside a div with class : chronoform , use this to hide the link by using different colors or whatever if you really can't pay, but of course the link is still exists at your page source.

 

The license is ONLY 25$ can be bought here :

 

Thank you!

 

ChronoEngine.com Team 

Joomla Templates and Joomla Tutorials