Jump to content

How to display different headers conditional on field value (solved)


Recommended Posts

Want to display a different header according to value of field from user authentication.  Code logic works fine, but the HTML I want to be executed does not work.

Here's a sample script.  The Italics part after the "if" statement works well on its own, but with the conditional code, it is ignored.  Rules can't be used (I think) as they do not operate with Header or Footer blocks in a Data Page.

<script>

if("[@authfield:User_Company_Name]" == "ABC Ltd"){

Welcome [@authfield:User_Name] to your account  &nbsp; <a href="https://www.myurl1/" target="_blank"><img alt="" src="https://myurl2.png" style="width: 50px; height: 10px; vertical-align: middle;" /></a>&nbsp;<a href="https://Myaccount.caspio.com/folderlogout">Logout</a>

}

Else{

Display an alternative header

}

</script>

Many thanks for any help/advice you may be able to give!

 

Link to comment
Share on other sites

Solved !  Now displaying user-specific logos.  After quite a few hours experimenting, now I can display logos (or whatever) in a Header in a Results page, that can be conditional on a table value.

The trick was to set variables & use document.write(variable).   

<script>
// var1 is the Company A logo (it's clickable & takes you to the home page)
// var2 is Company B logo (it's clickable & takes you to the home page)
var1='<img alt="" src="https://URL of Company A.png" style="width: 301px; height: 61px; vertical-align: top;" /> <br />&nbsp; &nbsp;Welcome [@authfield:User_Name] to your Company A account &nbsp; &nbsp; &nbsp;&nbsp;<a href="https://URL of Caspio logout">Logout</a>' ;
//
var2='<a href="http://URL of CompanyB/" target="_blank"><img alt="" src="http://URL of Company B logo.jpg" style="width: 100px; height: 80px; vertical-align: top;" /></a>&nbsp;&nbsp;<br />Welcome [@authfield:User_Name] to your CompanyBname account, powered by&nbsp;<a href="https://mycompanyURL home page" target="_blank"><img alt="" src="https://my company logo.png" style="width: 50px; height: 10px; vertical-align: middle;" /></a> &nbsp; &nbsp; &nbsp;&nbsp;<a href="https://URL of Caspio logout">Logout</a> ';
// Check company name in order to display appropriate logo
// Name obtained from user profile 
if("[@authfield:Customer_Company_Name]" == "CompanyAName"){
document.write (var1)
}
if("[@authfield:Customer_Company_Name]" == "CompanyBName"){
document.write (var2)
}
</script>

Link to comment
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...
×
×
  • Create New...