Forums

Help with check boxes

jmelwak 15 Jan, 2009
hi all i cannot get this figured out, i tried reading another post in the forum but still cannot get it to work. i just have checkboxes i want to show up in an email when form is submitted and its not working properly.

here is the form code.
<div style="padding-left:50px;"><div  class="form_item"><div class="form_element cf_heading"><h4 id="" class="cf_text">Take a second to fill out the below information and we will get back to you ASAP with a quote. Thank you for your interest. 'Submit'!</h4></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_checkbox">
  <label class="cf_label"><br>
</label>
  <div class="float_left"><strong>What is the purpose of your web design project? </strong><br>
    <input value="Sell_products and accept payment online" class="radio validate-one-required" id="Sell_products and accept payment online " name="sellproducts[]" type="checkbox">
    <label for="Sell_products and accept payment online" class="check_label">Sell_products and accept payment online</label>
  <br><input value="Market My Products And Services" class="radio" id="Market_my products and services" name="marketproducts[]" type="checkbox">
  <label for="Market_my products and services" class="check_label">Market My Products And Services</label><br><input value="Other (Please Explain More In The Additional Notes Section) " class="radio" id="Other_(please explain more in the Additional Notes section) " name="other[]" type="checkbox">
  <label for="Other_(please explain more in the Additional Notes section) " class="check_label">Other (Please Explain More In The Additional Notes Section) </label><br></div>
</div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_checkbox"><label class="cf_label"><strong><br>
</strong></label>
    <div class="float_left"><strong>What type of Web design services are you looking for?</strong><br>
  <input value="Design_of an entirely new Web site" class="radio validate-one-required" id="Design_of an entirely new Web site" name="designofnewwebsite[]" type="checkbox">
  <label for="Design_of an entirely new Web site" class="check_label">Design Of An Entirely New Web Site</label><br>
  
  <input value="Complete_redesign of an existing Web site" class="radio" id="
Complete_redesign of an existing Web site" name="redesignofexisting[]" type="checkbox">
  <label for="Complete_redesign of an existing Web site" class="check_label">
  
    Complete Redesign Of An Existing Web Site</label><br>
    <input value="Maintenance_or upgrade to an existing site" class="radio" id="Maintenance_or upgrade to an existing site" name="maintain[]" type="checkbox">
    <label for="Maintenance_or upgrade to an existing site" class="check_label">
    Maintenance Or Upgrade To An Existing Site</label><br></div></div>
    
<div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_checkbox"><label class="cf_label"><br>
</label>
    <div class="float_left"><strong>What is your estimated budget for this project? </strong><br>
    <input value="$0-$1000" class="radio validate-one-required" id="$0-$1000" name="0-1000[]" type="checkbox">
    <label for="$0-$1000" class="check_label">$0-$1000</label><br>
    
    <input value="$1000-$2000" class="radio" id="$1000-$2000" name="1000-2000[]" type="checkbox">
    <label for="$1000-$2000" class="check_label">$1000-$2000</label><br>
    
    <input value="$3000-$4000" class="radio" id="$3000-$4000" name="3000-4000[]" type="checkbox">
      <label for="$3000-$4000" class="check_label">
        $3000-$4000</label><br>
        
        <input value="$4000-$5000" class="radio" id="$4000-$5000" name="4000-5000[]" type="checkbox">
        <label for="$4000-$5000" class="check_label">
          $4000-$5000</label><br>
          
          <input value="$5000_or more" class="radio" id="$5000_or more" name="5000[]" type="checkbox">
          <label for="$5000_or more" class="check_label">
    $5000 Or More</label><br></div>
</div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_checkbox"><label class="cf_label"><br>
</label>
    <div class="float_left"><strong>How soon do you want your project to start?</strong><br>
 
  <input value="ASAP" class="radio validate-one-required" id="ASAP" name="asa[[]" type="checkbox">
  <label for="ASAP" class="check_label">ASAP</label><br>
  
  <input value="1_Week" class="radio" id="1_Week" name="1week[]" type="checkbox">
  <label for="1_Week" class="check_label">
    1 Week</label><br>
    
    <input value="2_Weeks" class="radio" id="2_Weeks" name="2weeks[]" type="checkbox">
    <label for="2_Weeks" class="check_label">
      2 Weeks</label><br>
      
      <input value="3_Weeks" class="radio" id="3_Weeks" name="3weeks[]" type="checkbox">
      <label for="
3_Weeks" class="check_label">
        3 Weeks</label><br>
        
        <input value="One_Month" class="radio" id="One_Month" name="onemonth[]" type="checkbox">
        <label for="
One_Month" class="check_label">
    One Month</label><br></div>
</div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_checkbox"><label class="cf_label"><br>
</label>
    <div class="float_left"><strong>What additional products and services are you interested in?</strong><br>
  
  <input value="Content_Management" class="radio" id="Content_Management" name="cms[]" type="checkbox">
  <label for="Content_Management" class="check_label">Content Management</label><br>
  
  <input value="Internet_Marketing" class="radio" id="Internet_Marketing & PPC" name="internetmarketing[]" type="checkbox">
  <label for="
Internet_Marketing & PPC" class="check_label">
    Internet Marketing & PPC</label><br>
    
    <input value="Search_Engine_Optimization" class="radio" id="Search_Engine Optimization" name="seo[]" type="checkbox">
    <label for="Search_Engine Optimization" class="check_label">
      Search Engine Optimization</label><br>
      
      <input value="Print_Services" class="radio" id="Print_Services" name="printing[]" type="checkbox">
      <label for="
Print_Services" class="check_label">
    Print Services</label><br></div>
</div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textarea"><label class="cf_label">Please describe your company, the project, and any additional requirements you may have.<br>
</label>
<textarea class="cf_inputbox" rows="3" id="text_6" cols="30" name="text_6"></textarea></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_text"><span class="cf_text">Please provide your contact info so we can get back to you as soon as possible.</span></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Your Name:</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_8" name="text_8" type="text"></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Your Email Address:</label><input class="cf_inputbox validate-email" maxlength="150" size="30" id="text_9" name="text_9" type="text"></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Day Time Phone:</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_10" name="text_10" type="text"></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Evening Phone:</label><input class="cf_inputbox" maxlength="150" size="30" id="text_11" name="text_11" type="text"></div><div class="clear"> </div></div><div  class="form_item"><div class="form_element cf_button"><input value="Submit" name="undefined" type="submit"></div><div class="clear"> </div></div></div>

and here is the email template code:
Take a second to fill out the below information and we will get back to you ASAP with a quote. Thank you for your interest. 'Submit'!
)What is the purpose of your web design project?
{sellproducts}Sell Products And Accept Payment Online

{marketproducts}Market My Products And Services

{other}Other (Please Explain More In The Additional Notes Section)

What type of Web design services are you looking for?

{deisgnofnewwebsite}Design Of An Entirely New Web Site
{redesignofexisting} Complete Redesign Of An Existing Web Site
{maintain}Maintenence

What is your estimated budget for this project?
{0-1000}$0-$1000
{1000-2000} $1000-$2000
{3000-4000} $3000-$4000
{5000} $5000 Or More

How soon do you want your project to start?
{ASAP}ASAP
{1week} 1 Week
{2weeks} 2 Weeks
{3weeks} 3 Weeks
{onemonth} One Month

What additional products and services are you interested in?
{cms}Content Management
{internetmarketing} Internet Marketing & PPC
{seo} Search Engine Optimization
{printing} Print Services

Please describe your company, the project, and any additional requirements you may have. {text_6}

Please provide your contact info so we can get back to you as soon as possible.
Your Name:{text_8}
Your Email Address:{text_9}
Day Time Phone:{text_10}
Evening Phone:{text_11}

any help is greatly appreciated i cannot get this to work 😟
jmelwak 15 Jan, 2009
well i got the checks to work now i am getting an error when submitting and i am checking all the boxes to see if they work....

Illegal variable _files or _env or _get or _post or _cookie or _server or _session or globals passed to script.
GreyHead 15 Jan, 2009
Hi jmelway,

Let's look at one checkbox groups form your code( re-formatted for clarity)
<div  class="form_item">
    <div class="form_element cf_checkbox">
        <label class="cf_label"><br></label>
        <div class="float_left"><strong>What is the purpose of your web design project? </strong>
            <br>
            <input value="Sell_products and accept payment online" class="radio validate-one-required" id="Sell_products and accept payment online " name="sellproducts[]" type="checkbox">
            <label for="Sell_products and accept payment online" class="check_label">Sell_products and accept payment online</label>
            <br>
            <input value="Market My Products And Services" class="radio" id="Market_my products and services" name="marketproducts[]" type="checkbox">
            <label for="Market_my products and services" class="check_label">Market My Products And Services</label>
            <br>
            <input value="Other (Please Explain More In The Additional Notes Section) " class="radio" id="Other_(please explain more in the Additional Notes section) " name="other[]" type="checkbox">
            <label for="Other_(please explain more in the Additional Notes section) " class="check_label">Other (Please Explain More In The Additional Notes Section) </label>
            <br>
        </div>
    </div>
    <div class="clear"> </div>
</div>

First off this version of the ChronoForms wizard does a rubbish job with converting complex labels into 'name' and 'id' attributes. You cannot legally have a 'name' with spaces or special characters - yet the wizard only replaces the first space with an underline and ignores all special characters.

You've already replaced the names, you also need to replace the ids to make
id="Other_(please explain more in the Additional Notes section) "
into something like
id="purpose_other"

Because this is a checkbox block you woudl like to have the results returned in one variable (an variable array for checkboxes, a single variable for radio buttons). For this each member needs to have the *same* name e.g. name='purpose[]' (ids should all be unique). At the same time we can simplify the label 'for' attributes.

Lastly the values probably don't need to be quite as long as the label texts.

Making these changes your code becomes
<div  class="form_item">
    <div class="form_element cf_checkbox">
        <label class="cf_label"><br></label>
        <div class="float_left"><strong>What is the purpose of your web design project? </strong>
            <br>
            <input value="Sell online" class="radio validate-one-required" id="purpose_sell" name="purpose[]" type="checkbox">
            <label for="purpose_sell" class="check_label">Sell_products and accept payment online</label>
            <br>
            <input value="Market" class="radio" id="purpose_market" name="purpose[]" type="checkbox">
            <label for="purpose_market" class="check_label">Market My Products And Services</label>
            <br>
            <input value="Other" class="radio" id="purpose_other[]" name="purpose[]" type="checkbox">
            <label for="purpose_other " class="check_label">Other (Please Explain More In The Additional Notes Section) </label>
            <br>
        </div>
    </div>
    <div class="clear"> </div>
</div>

This will returns an array entry in the $_POST array like
['purpose'] => array([0] => 'Sell online', [1] => 'Other')

ChronoForms will unpack this in the OnSubmit area into a comma separated string like 'Sell online, Other'

The wizard also produces correspondingly bad email template code
What is the purpose of your web design project?
{sellproducts}Sell Products And Accept Payment Online

{marketproducts}Market My Products And Services

{other}Other (Please Explain More In The Additional Notes Section)
You only need one line for this checkbox array so you can replace all of this block with
What is the purpose of your web design project? {purpose}

Bob

PS I'm not sure what's causing the new errors but they may arise from some of the bad ids.
This topic is locked and no more replies can be posted.