Two checkbox arrays

jimstrong 21 Nov, 2008
Hi again

I have two arrays in my form both of which can be left blank by the user. I have found that if the checkboxes are left blank, the first array does not show up on the email at all (and that is what I am trying to achieve) but the second appears as e.g. " {course_style}".

If I change the order of the code in the form, then the second one appears e.g. {interest}.

Should CF be able to handle two arrays?

I'm attaching the relevant bits of code.

Thanks a lot

Jim

Form Code snippet 1
    <div class="form_element cf_textbox" style="position: absolute; left: 0px; top: 287px;">Please select all areas / courses of interest:-</div>
    <div class="form_element cf_textbox" style="position: absolute; left: 0px; top: 307px;">
      <input value="Advanced Supervision Skills" name="interest[]" type="checkbox">
      <label> Advanced Supervision Skills</label>
    </div>
    <div class="form_element cf_textbox" style="position: absolute; left: 0px; top: 329px;">
      <input value="Becoming a Coaching Supervisor" name="interest[]" type="checkbox">
      <label> Becoming a Coaching Supervisor</label>
    </div>
    <div class="form_element cf_textbox" style="position: absolute; left: 247px; top: 446px;">
      <input value="Supervision/Training for Clinical Psychologists" name="interest[]" type="checkbox">
      <label> Supervision/Trg for Clinical Psychologists</label>
    </div>


Form Code snippet 2
 <div class="form_element cf_textbox" style="position: absolute; left: 0px; top: 565px;">How would you prefer to receive the course, were you to attend? (You may select more than one option)</div>    
<div class="form_element cf_textbox" style="position: absolute; left: 85px; top: 580px;">
      <input value="In House" name="course_style[]" type="checkbox">
      <label>In House</label>
    </div>   
<div class="form_element cf_textbox" style="position: absolute; left: 220px; top: 580px;">
      <input value="Masterclass" name="course_style[]" type="checkbox">
      <label>Masterclass or Open Course</label>
    </div>


Email Template Code snippet
<p><strong>They expressed interest in these areas of supervision or courses (if entered):-</strong></p>
<div class="form_element cf_checkbox"><label class="cf_label"></label><span>{interest}</span></div>
<p>Course Style (if entered):-</p>
<div class="form_element cf_checkbox"><label class="cf_label"></label><span>{course_style}</span></div>
Max_admin 21 Nov, 2008
Hi Jim,

Chronoforms should handle this and the 2 arrays should not affect each other at all!

did you test this well ? is this V3.0 stable ?

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jimstrong 21 Nov, 2008
Hi Max - thanks for confirming that CF should handle it. I suspected so and that means that I must focus on my code to find the answer.

Yes I'm on V3.0 Stable and I tested it as well as I could. However I've just run the page through Total Validator and have picked up some errors, so will concentrate on analysing and resolving those before posting any further findings here.

Thanks a lot

Jim
jimstrong 22 Nov, 2008
I took a slightly different approach and was able to replicate the problem:-

I used the Form Wizard to create two sets of three checkboxes and then altered the html to create two array names and added a submit button. These were the only html changes I made.

I then submitted the form with all checkboxes unchecked and the result was as reported above.

Any thoughts as to how to avoid the second array name appearing would be much appreciated.

Thanks a lot

Jim


Email Result
From: Anyone [anyone@anywhere.me.uk]
To: Anyone [anyone@anywhere.me.uk]
Subject: Test
Click Me to Edit
If entered:-
If entered:- {check2}

Form code
<div class="form_item">
  <div class="form_element cf_checkbox">
    <label class="cf_label">Click Me to Edit</label>
    <div class="float_left">
      <input value="check 1" class="radio" id="check_1" name="check1[]" type="checkbox">
      <label for="check_1" class="check_label">Check 1</label>
      <br>
      <input value="check 2" class="radio" id="check_2" name="check1[]" type="checkbox">
      <label for="check_2" class="check_label">Check 2</label>
      <br>
      <input value="check 3" class="radio" id="check_3" name="check1[]" type="checkbox">
      <label for="check_3" class="check_label">Check 3</label>
      <br>
    </div>
  </div>
  <div class="clear"> </div>
</div>
<div class="form_item">
  <div class="form_element cf_checkbox">
    <label class="cf_label">Click Me to Edit</label>
    <div class="float_left">
      <input value="check 4" class="radio" id="check_4" name="check2[]" type="checkbox">
      <label for="check_4" class="check_label">Check 4</label>
      <br>
      <input value="check 5" class="radio" id="check_5" name="check2[]" type="checkbox">
      <label for="check_5" class="check_label">Check 5</label>
      <br>
      <input value="check 6" class="radio" id="check_6" name="check2[]" type="checkbox">
      <label for="check_6" class="check_label">Check 6</label>
      <br>
    </div>
  </div>
  <div class="clear"> </div>
</div>
<div class="form_item"><div class="form_element cf_button"><input value="Submit" name="undefined" type="submit"></div>


Email Code
<div class="form_item">
<div class="form_element cf_checkbox"><label class="cf_label">Click Me to Edit</label>
<div class="float_left"><span>If entered:- {check1}</span></div>
</div>
</div>
<div class="form_item">
<div class="form_element cf_checkbox">
<div class="float_left"><span>If entered:- </span><span>{</span><span>check2</span><span>}</span></div>
</div>
</div>
GreyHead 22 Nov, 2008
Hi Jim,

This doesn't look correct:
<div class="float_left"><span>If entered:- </span><span>{</span><span>check2</span><span>}</span></div>
there are too many spans. Try replacing this with
<div class="float_left">If entered:- {check2}</div>


Bob
jimstrong 22 Nov, 2008
Thanks Bob

Indeed in doesn't look correct! Doh!

However, replacing with your correct code, I'm still getting the same result.😟

Jim
Max_admin 22 Nov, 2008
Hi Jim,

Backup your form and add it here please, remove any private data of course!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jimstrong 23 Nov, 2008
HI Max

Form attached as requested (I had to change the extension name to ".zip" but it is just a cfbak file).

Thanks

Jim
Max_admin 23 Nov, 2008
Hi Jim

I can't understand why this happens but here is a fix!!

in chronocontact.php find this line:
$names = explode(",", $rows[0]->fieldsnames);


make it:

$names = explode(",", str_replace("[]", "" , $rows[0]->fieldsnames));


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jimstrong 23 Nov, 2008
Thanks Max - that definitely seems to have done the trick!

By the way, I noted that "course_style[]" appeared in the auto-generated fields and thought that might also have had a connection to the problem.

I'm really enjoying CF now that I have got to grips with it - great product!

Thanks again

Jim
This topic is locked and no more replies can be posted.