Jump to content
Sign in to follow this  
caspio

JS: Show/hide A Custom Link On Results

Recommended Posts

JavaScript Solution: Show/Hide a custom link on results page based on a Yes/No field

Feature Description:

This JavaScript solution shows how to display or hide a custom link in HTML block on a results page of a Search and Report DataPage based on the value of a Yes/No field. A typical example is, to only display the custom "details" link if the field value "Yes".

Implementation:

This solution can be used "as-is", without any changes if

a. It is used on a results page of a Search and Report DataPage.

b. There is a Yes/No field named Approved in the table.

To use this solution copy and paste the code below, inside the HTML block of the results page using the Caspio Bridge DataPage Wizard.

<span id="cbLinkCtnr[@cbRecordIndex#]"></span>
	<script type="text/javascript">
		/* 1 - get the Yes/No field */
		var cb_boolean = '[@field:Approved]';
		if (cb_boolean == 'Yes') {
			/* 2 - construct the custom link */
			document.getElementById("cbLinkCtnr[@cbRecordIndex#]").innerHTML = '[url="http://www.google.com/"]Enter Google[/url]';
		}
	</script>

Tips for Customization

a. To use this script with a different field name, modify the line immediately below comment 1 by replacing "Approved" with the appropriate field name.

b. Customize the custom link in various ways. For example, to pass Unique ID field as a parameter in the URL, change the line of code immediately below comment 2 to:

document.getElementById("cbLinkCtnr[@cbRecordIndex#]").innerHTML = '[url="http://URL&UniqueID=[@field:UniqueID]"]Custom Link[/url]';

Where URL is the real URL of the web page the custom link directs to.

Tested Browsers

This JavaScript solution was tested on the following platforms and Internet Browsers only.

# MS Windows - IE 8.0, Firefox 3.6.3, Chrome 4.1, Safari 4.0.5

# Macintosh - Firefox 3.6.3, Safari 4.0.3

Disclaimer: Use these JavaScript solutions at your own risk! They are provided to assist you in the customization of your programs and while we believe they work properly, by using them you accept all responsibility about them and confirm that they are not a feature of Caspio's platforms and as such are provided "as is" without any warranties, support or guarantees.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...