Skip Navigation

[Resolved] Interactive single cpt template

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 2 voices.

Last updated by jillT 3 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#2026107

Site on local, not available online.

Is it possible to have a list with a checkbox that the visitor can click to put in a tick and it changes the fontstyle of that line to strike? Like the Ingredients list on this plugin (scroll down the page): hidden link

If so, how would I go about it please?

#2026185

Hi,

Thank you for contacting us and I'd be happy to assist.

To make a list of checkboxes items that show text label as strikethrough when checked, you can structure the HTML list in this format:


<ul class="ingredient-list">
    <li>
        <input type="checkbox" name="ingredient 1" value="1" id="ingredient1">
        <label for="ingredient1">ingredient item number 1</label>
    </li>
    <li>
        <input type="checkbox" name="ingredient 2" value="2" id="ingredient2">
        <label for="ingredient2">ingredient item number 2</label>
    </li>
    <li>
        <input type="checkbox" name="ingredient 3" value="3" id="ingredient3">
        <label for="ingredient3">ingredient item number 3</label>
    </li>
    <li>
        <input type="checkbox" name="ingredient 4" value="4" id="ingredient4">
        <label for="ingredient4">ingredient item number 4</label>
    </li>
</ul>

And to style the label for the checked checkbox as strikethrough text, you can include the CSS code:


ul.ingredient-list li {
list-style: none;
}

ul.ingredient-list li input[type=checkbox]:checked+label {
text-decoration: line-through;
}

Demo: hidden link

I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar

#2026365

thank you. I can understand the html, but I'm not sure how to get that dynamically.

I should have explained a bit more, sorry

It is a custom post type, with a single line custom field type that allows multiple instances.
What block should I use and how would I display each instance?

#2027087

Thank you for sharing these details.

For dynamically generating this HTML through a repeating custom field, you can use the "wpv-for-each" shortcode:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-for-each

For example, suppose the field's slug is "ingredient-items":


<ul class="ingredient-list">
[wpv-for-each field="wpcf-ingredient-items"]
<li>
<label><input type="checkbox" name="" value="1"> <span> [types field="ingredient-items"][/types] </span></label>
</li>
[/wpv-for-each]
</ul>

The updated CSS code will be:


ul.ingredient-list li {
list-style: none;
}
 
ul.ingredient-list li input[type=checkbox]:checked+span {
text-decoration: line-through;
}

#2028143

Thank you, that worked beautifully!