Skip Navigation

[Resolved] CRED form: set some options of an invisible checkboxes field checked

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 3 voices.

Last updated by Lara 3 years, 7 months ago.

Assisted by: Waqar.

Author
Posts
#1762915

Tell us what you are trying to do?

I have a checkboxes field with two options. By default they are unchecked. The user only gets access to certain areas, if the according option is selected in the checkboxes field as checked.

I try to create a CRED form and after the form submission one of the selected options should be checked - while the entrire checkboxes field should stay invisible.

Can I achieve this somehow with javascript? I did an extensive research here in the forum, but I couldn't find a useful solution.

Is there any documentation that you are following?
no

Is there a similar example that we can see?
no

What is the link to your site?
Site under development

#1763007

Hello,

Please elaborate the questions with more details:

I try to create a CRED form and after the form submission one of the selected options should be checked - while the entrire checkboxes field should stay invisible.

How do you setup the custom checkboxes field?
How do you want to setup "after the form submission one of the selected options should be checked"?
Where and how do you want to set "the entrire checkboxes field should stay invisible"?

I need to test it in my localhost, thanks

#1763235
2020-09-01-Toolset_Checkboxes.PNG

Hello,

the setup should look like the following..

[credform]
  
<div style="display: none;">

<!-- select option 1 in the following checkboxes field. The user shouldn't see it, so I need to select something on his behalf -->
[cred_field field="rechte-benutzer" force_type="field" class="form-check-input" output="bootstrap"]
</div>
  
[cred_field field='form_submit' output='bootstrap' value='JA, BITTE FREISCHALTEN' class="Ort_betreten"]
[/credform]

If [cred_field field="rechte-benutzer" force_type="field" class="form-check-input" output="bootstrap"] would be a select field,
I would set it up with value="option1". I never did something like that with Checkboxes, so I am a little bit lost...

#1764105

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for sharing these details.

Luo is on a holiday today, so I'll be following up on this ticket.

To automatically check the first option in the checkbox field, you can include some custom script in the form's "JS editor":


jQuery( document ).ready(function() {
    jQuery('.wpt-form-set-checkboxes-wpcf-field-slug li.wpt-form-item:nth-of-type(1) input[type=checkbox]').prop("checked","true");
});

Note: Please replace "field-slug" with the actual slug of your checkboxes type custom field (i.e. rechte-benutzer )

I hope this helps and please let me know how it goes.

Note: in case it doesn't work for some reason, please share the link to a page where this form can be seen.

regards,
Waqar

#1764413

Awesome solution.
Many thanks Waqar.

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.