MikeN Posted June 19, 2019 Report Share Posted June 19, 2019 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 <a href="https://www.myurl1/" target="_blank"><img alt="" src="https://myurl2.png" style="width: 50px; height: 10px; vertical-align: middle;" /></a> <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! Quote Link to comment Share on other sites More sharing options...
MikeN Posted June 20, 2019 Author Report Share Posted June 20, 2019 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 /> Welcome [@authfield:User_Name] to your Company A account <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> <br />Welcome [@authfield:User_Name] to your CompanyBname account, powered by <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> <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> Quote Link to comment Share on other sites More sharing options...
MikeN Posted June 20, 2019 Author Report Share Posted June 20, 2019 Don't forget to disable Ajax to force the javascript to be executed every time the page is displayed, otherwise it is often only executed if you refresh the page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.