Buy Now
Sign in

show/hide HTML fields based on the content of dinamyclly-filled hidden fields?

yorai85 , October 24 2017
Y
yorai85
hello there,

i have a blog website with about 10 authors, and i'm creating a contact form to be placed on the bottom of each blog item, near the "about the author" box. that form will be used to contact the author of the currently-viewed article.

i want to use 1 form for all the authors - and set some values based on to HTML elements in the page: the author's name & the author's email.
so i've created some hidden fields and custom JS to catch these values - and i'm using them in the email actions - to decide where to send the email and which name to use.

but - i also want to change the form's title & intro-text based on that information. so that the form will display different title & intro-text based on the author of the currently-viewed article.

i was thinking to create some custom HTML element, 1 for each author, and then hide/show them based on the content of the hidden field with the author's name. but the hidden fields in CF does not have any options for setting events.
the solution to this seemes to be using regular fields instead of hidden fields, and hidding them "manualy". but i wanted to ask if there is maybe a better way which i am not considering?

thank you very much
yorai
admin
Hi Yorai,

Do not use HTML fields, just get the article id and load the info using a "Read data" action then use the data to send the email to the correct author.

Best regards
Max
If your main question got answered then please mark the answer using the button!​

Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
Y
yorai85
thank you max, i don't know the "read data" action, will check it out.

but as far as i understand you that would apply only to the emails - is there a way to change the show/hide custom HTML areas in the form, based on the content of that information?

for example if the author's name is "Bill Gates", then a specific HTML area with information about Bill Gates will be displayed.
but if the author name is "Steve Jobs" then a different HTML arae will be displayed, with information about Seteve Jobs, and the area with information about Bill Gates will be hidden.

in the form i will create a different HTML area for each author (containing it's information), and i want to display only the arae about the current author, while the others are kept hidden.

yorai
admin
Hi Yorai,

Yes you can do that, did you check the "dynamic dropdown" demo form for how to reload a dropdown ? you just do the same but instead you load a "segment area", and add your custom HTML code inside that segment.

The different content of course can be loaded from a database or some other way, based on your implementation.

Best regards
Max
If your main question got answered then please mark the answer using the button!​

Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
Y
yorai85
Thank you max, i will do that.
yorai