07-19-2023, 05:27 PM
I am using a CMS that allows data place holders with braces, like so:
Name: {First_Name} <br>
Email: {Email} <br>
Phone: {Phone} <br>
However it doesn't give me any way to do conditional output, like I can't hide the Phone line if the phone field is blank.
The CMS doesn't allow javascript or server side code. I came up with this trick:
Name: {First_Name} <br>
Email: {Email} <br>
<div style="display:none{Phone}">Phone: {Phone} <br></div>
If the person has no phone number, the div ends up display:none, but if they do, the div ends up with a nonsense value for display, and the whole div shows up.
It works in IE8, IE9, FF14, Chrome
Any reason I shouldn't do this?
Name: {First_Name} <br>
Email: {Email} <br>
Phone: {Phone} <br>
However it doesn't give me any way to do conditional output, like I can't hide the Phone line if the phone field is blank.
The CMS doesn't allow javascript or server side code. I came up with this trick:
Name: {First_Name} <br>
Email: {Email} <br>
<div style="display:none{Phone}">Phone: {Phone} <br></div>
If the person has no phone number, the div ends up display:none, but if they do, the div ends up with a nonsense value for display, and the whole div shows up.
It works in IE8, IE9, FF14, Chrome
Any reason I shouldn't do this?