Home ›  Tap Forms Pro ›  Script Library ›  tagHandler ▾ 

Category: Script Library

tagHandler

tagHandler is a class that simplifies handling of tags in strings (aka text fields). It provides following features:

  • initialize tag object
  • add tag
  • remove tag
  • sort tags
  • toString

An example application can be found in the tips&tricks section.

Usage

This script is a helper script that is launched from other applications. It doesn't do anything on it's own.

To use this class, first it needs to be loaded:

// load tagHandler class if it is not already loaded
if (typeof tagHandler === 'undefined')
    document.getFormNamed('Scripts').runScriptNamed('tagHandler');
  • new tagHandler(string, separator:=","): Instantiate a new tagHandler object, initialized with the provided string. If no string is supplied, the object will be empty. You can also specify an optional separator. Any leading or trailing whitespace in the string's items will be automatically removed.
let tags = new tagHandler("jan, feb, mar, apr");
  • add: Add new tag to the tagHandler object
tags.add("dec")
  • remove: Remove new tag from tagHandler object
tags.remove("jan")
  • sort(fcnt): Sort the tags within the tagHandler object. By default, the tags are sorted alphanumerically. Alternatively, you can provide a custom sorting function.
// alphabetical sort
tags.sort();

// custom sort (numeric)
tags.sort((a,b) => a - b);
  • toString(separator): Returns string from tagHandler object. A custom separator may be provided to delimit the different tags.
console.logs(tags.toString("|"));

Installation

The tagHandler script is installed using the scriptHandler script about which you can learn more over here. It is installed in the Scripts form.

Dependencies

none

ChangeLog

Link to ChangeLog

Author

Do you like this script? Are you using it? Please consider supporting me by buying me a coffee!

Buy Me Coffee Link

Thanks!


Last modified: Apr 24, 2025 6:30:10 PM


Tap Forms Consulting

Do you need help writing scripts for your Tap Forms Pro database? I'm happy to help you. Contact me to discuss your idea or project.


Web Design Consulting

Do you need help designing your web site or getting Backlight working the way you want? Contact me to discuss your needs.


Buy me a Coffee

If you like what I share here, please consider buying me a coffee or a print. This helps keeping me motivated to continue posting. Thank you!

Buy Me A Coffee