• Resolved kokoruz

    (@kokoruz)


    I wondering how I could set a value to a checkbox that is different than the label/choices

    ie., If I have an option/checkbox “I’d Like More Information” I’d rather set the value to “Yes” instead of the label “I’d Like More Information”.

    I thought about using the acceptance option but that can’t help me either.

    Can this be done?

    http://wordpress.org/plugins/contact-form-7/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    You can use pipe for that.

    Example:

    [checkbox checkbox-123 "I'd Like More Information|Yes"]

    Thread Starter kokoruz

    (@kokoruz)

    Thanks so much for that info but I can’t seem to make this work.

    I have the following,
    [checkbox Newsletter "Sign-up for our Newsletter|Opt In"]
    and it generates the following code
    <span class="wpcf7-list-item"><input type="checkbox" name="Newsletter[]" value="Sign-up for our Newsletter">&nbsp;<span class="wpcf7-list-item-label">Sign-up for our Newsletter</span></span>

    You can see it’s not giving the correct value of ‘Opt In’

    I applied this same pipe declaration to a drop down box for US States
    [select* Location include_blank "Alabama|AL" "Alaska|AK" "Arizona|AZ" "Arkansas|AR" "California|CA" "Colorado|CO" "Connecticut|CT" "Delaware|DE" "District Of Columbia|DC" "Florida|FL" "Georgia|GA" "Hawaii|HI" "Idaho|ID" "Illinois|IL" "Indiana|IN" "Iowa|IA" "Kansas|KS" "Kentucky|KY" "Louisiana|LA" "Maine|ME" "Maryland|MD" "Massachusetts|MA" "Michigan|MI" "Minnesota|MN" "Mississippi|MS" "Missouri|MO" "Montana|MT" "Nebraska|NE" "Nevada|NV" "New Hampshire|NH" "New Jersey|NJ" "New Mexico|NM" "New York|NY" "North Carolina|NC" "North Dakota|ND" "Ohio|OH" "Oklahoma|OK" "Oregon|OR" "Pennsylvania|PA" "Rhode Island|RI" "South Carolina|SC" "South Dakota|SD" "Tennessee|TN" "Texas|TX" "Utah|UT" "Vermont|VT" "Virginia|VA" "Washington|WA" "West Virginia|WV" "Wisconsin|WI" "Wyoming|WY"]
    and this did not work as well. What am I doing wrong?

    Lastly is it possible when using the include_blank option to assign it some text other than ‘—‘ something like select a state or location?

    <option value="">---</option><option value="Alabama">Alabama</option><option value="Alaska">Alaska</option>

    Thank You!

    Thread Starter kokoruz

    (@kokoruz)

    I feel silly. The pipe worked just fine. I was confused why the value in the html displayed the way it did but it processed the form with no issue.

    Thank You.

    If you have any insight on replacing the ‘—‘ for something more descriptive please let me know. I looked through the website for answers but did not find anything.

    Thanks Again!!!

    How about for acceptance? I’d like the email to show “Yes” instead of 1 if accepted (checked) and “No” if submitted unchecked. I used [acceptance acceptance id:acceptance "Accepted|Yes"]

    I know this is a slightly old post, but in case you haven’t fixed this or someone else comes across it, for your secondary question on replacing the ‘—‘ with something more descriptive, you can add the following to your theme’s functions.php:

    add_filter("wpcf7_form_elements","yourtheme_replace_cf7_dashes");
    function yourtheme_replace_cf7_dashes($output){
    	return str_replace("<option >---</option>","<option >Enter your descriptive text here</option>",$output);
    }

    Oh, and I just figured out your main problem too, which is what brought me to this post in the first place – Contact Form 7 *does* actually replace the correct value, just not in the source! It replaces it in the backend and sends the value you want to your e-mail.

    The key was hidden on this page – http://contactform7.com/selectable-recipient-with-pipes/ – “By using this procedure, the email addresses are revealed over the Internet and this is not good.” Of course, if CF7 just stuck it in the value attribute, this wouldn’t solve much of a problem!

    Hope that helps you, or someone else too! Was scratching my head until I saw that, tested by actually sending an email, and voila.

    “By using this procedure, the email addresses are revealed over the Internet and this is not good.”

    But what if we just want to deal with the U.S. states, e.g.”Alabama|AL” “Alaska|AK”
    which is nothing to do with safety.
    Is there any way to get the value of that select box before submitting the form?
    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Check Box Value’ is closed to new replies.