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
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
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...
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
Awesome solution.
Many thanks Waqar.
My issue is resolved now. Thank you!