Jump to content
Sign in to follow this  
rush360

Hide HTML Blocks in Detail Page

Recommended Posts

I would like to Hide  HTML block(s)   when the value of one of the fields called in the HTML Block is blank.    Below the HTML from one of the blocks. I would like to hide this block if the field Zip3 is blank: 

<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">[@field:Address3_Type]<br />
[@field:Address3_Time@]&nbsp;on [@field:Address3_Time*]</div>

<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">Address:<br />
[@field:Address3]<br />
[@field:City3], [@field:State3]<br />
[@field:Country3], [@field:Zip3]</div>

I also have 3 other    similar HTML Blocks that would be hidden if fields Zip4, Zip5 & Zip6 are blank. 

Share this post


Link to post
Share on other sites

If you want to hide the info on result page of some kind, give your DIV an ID (use "box1") then try this:

<script type="text/javascript">
document.addEventListener('DataPageReady', window.onload = function(){ 

var x = document.getElementsByName("InsertRecordZip3")[0].value;
	
if (x == "") {
  document.getElementById("box1").style.display = 'none';
       alert("Nothing entered - box hidden");
} 
	else {
document.getElementById("box1").style.display = 'block';
 alert("Word entered - box not hidden");
 }

});
</script>

<!-- add a style tag, with "box1" display set to 'block', then update your code for the DIV as below -->
<style> #box1 {display:block}</style>

<div id="box1" style="background:#eee;border:1px solid #ccc;padding:5px 10px;">Address:<br />
[@field:Address3]<br />
[@field:City3], [@field:State3]<br />
[@field:Country3], [@field:Zip3]</div> 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...