I am looking to display different page content depending on what the user selects using the dataform checkbox feature.
Example: I give the user several choices using checkboxes
"Do you want onions on your pizza - yes / no".
"Do you want pepperoni on your pizza - yes / no"
If the user selects yes for onions then certain onion related content is shown on the page. If the user selects yes for pepperoni then different pepperoni content is shown on the page. If the user selects yes ofr onions and yes for pepperoni then different content is shown, etc. etc.
I can't seem to find a way to make decisions based on the result of the checkbox selection!
That's because you can't. This can't even be done with standard HTML forms!
You'd need to make changes to the HTML on the fly … JavaScript might be able to do that, but you'd have trouble getting it to work on Wikidot due to HTML being iframed (for security reasons).
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
Actually, there is a way, but is is very messy. It requires includes.
Since the form uses "1" for checked and "0" for unchecked, you can make two includes for each instance:
- inc:onion0
- inc:onion1
On inc:onion0, put nothing. On inc:onion1, put your onion content. Using a live template or ListPages, recall the content:
[[include inc:onion%%form_data{onion}%%]]
Timothy Foster - @tfAuroratide
Auroratide.com - Go here if you're nerdy like me
Thank you Timothy,
I think this may just work for what I have in mind. I will test this new [[include]] knowledge onto my page and see what happens.
Steven, Yes my example did come from what I learned from your page. You could improve your page by showing the code of how your examples work. I studied your onion and pepperoni example many times, however without seeing the code of what you did I could not figure it out.
Strange the way you formulate your example… it has many resemblance with my page, could this be coincidence? I also see that you added a page on my site.
Anyway…the answer ofyour question is illustrated here if I am not mistaking.
http://a-simple-plan.wikidot.com/checkbox
A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.