-
AuthorPosts
-
May 16, 2021 at 8:22 pm #1300587
Hi,
I want to implement a function in a form, which enables an interaction between a click in a checkbox and shown text.
I have a handful of checkboxes and in case which one is klicked, there should be a different text.Something like this:
<!DOCTYPE html> <html> <body> <p>Display some text when the checkbox is checked:</p> <input id="avia_2_1" class="input_checkbox" name="avia_2_1" type="checkbox" onclick="myFunction()" value="true"/> <label for="avia_2_1">Abzüglich 300,00 € Frühbucherrabatt bis zum 01.07.2021</label> <p id="text" style="display: none;">Gesamt: 3.600,00 EUR</p> <script> function myFunction() { var checkBox = document.getElementById("avia_2_1"); var text = document.getElementById("text"); if (checkBox.checked == true){ text.style.display = "block"; } else { text.style.display = "none"; } } </script> </body> </html>
But this is static – and doesn’t use values. How can I set values to each checkbox by hand and show these values after clicking? Or do you have other ideas, for example with css attribute “content”?
You can find this behaviour on the old site of my client in the form-area “Zahlungsart auswählen”. Just click a check-box and you see how it works.
https://www.akademie-steuerfachwirte.de/menu_anmeldung_2021/lehrgang/anmeldung/steuerfachwirt2021.htm
Here is the new site:Wenn you click on the last item “Abzüglich 300,00 € Frühbucherrabatt bis zum 01.07.2021” before the label IBAN, you can see a static implementation, but its buggy (the checkbox is not shown?). And will not send the right things in the mail-process, right?
So how to handle this?
Thanks in advance
TimMay 16, 2021 at 8:46 pm #1300590I set an formular-element with code, but the state of <p> is not set from “none” (p hidden) to block p shown) – wich functions in my examble above…..
Here you can find it: https://www.w3schools.com/code/tryit.asp?filename=GQKUF2Y9NAGV
It works, but not in enfold-form…
Any ideas?
May 17, 2021 at 10:35 am #1300673Hi,
after founding, that this gets to complex and that the handling of errors is really bad, I decide to use a plugin with conditional-file logic, so you can close this ticket. But I will open one for bad handlihg with errors in the form.Best Regards
Tim -
AuthorPosts
- The topic ‘How to set values for input-tags and show them after click?’ is closed to new replies.