Jump to content
  • 0

How to create a conditional link?



Good day fellow Caspio developers,

I have a DataPage where I have set up a link using the Link Menu generator found at https://b4.caspio.com/dp.asp?AppKey=a3012000cb4d6f2877864fd4a875 that delivered the following script (where I have added a little font formatting too):

<span style="font-size:12px;"><span style="font-family:tahoma,geneva,sans-serif;"><a class="cbMenuItem" href="#" onclick="window.open(&quot;https://c0esh337.caspio.com/dp/cdemyDataPageAppKey?Dest_Country=[@field:Country_Name]&amp;Company_Name=[@field:Importer_Of_Record]&quot;,&quot;mywindow&quot;, &quot;menubar=1,resizable=1,width=500,height=700&quot;)">View IOR Contact Details</a></span></span>

The general idea here is that when the user clicks on the link, it opens up a pop-up page displaying the Importer_Of_Record contact details and it works just fine for that purpose.

However, there are instances in my data where there is no record in the Importer_Of_Record field and so when this is the case I would like the script to recognise this fact and hide the link.

Is this possible and if so what changes do I need to make to my script?

Any help is much appreciated!


Stephen :)

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Hi @Stepford,

What datapage do you use? 

I have a Tabular Report datapage with an HTML block in which I have a JS which display the link to a pop-up based on the condition.

Here is an example of Javascript code I`ve used:

<div id='record[@cbRecordIndex#]'></div>

<script type="text/javascript">

document.addEventListener('DataPageReady', function (event) {
       if ("[@field:Name]" == "Jalian Corp") {
document.getElementById("record[@cbRecordIndex#]").innerHTML="<a class='cbMenuItem' href='#' onclick='window.open(\"https://c3fot067.caspio.com/dp/498C4000f7c51a179b034f26a6a5\", \"mywindow\", \"menubar=1,resizable=1,width=500,height=500\")'>Link</a>";
else {
document.getElementById("record[@cbRecordIndex#]").innerHTML="Profile In Progress</strong>";

Hope this helps.



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.

Answer this question...

×   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.

  • Create New...