Count number of list items in a field
- This topic has 1 reply, 2 voices, and was last updated 6 years, 2 months ago by .
Viewing 1 reply thread
Viewing 1 reply thread
- You must be logged in to reply to this topic.
Home › Forums › Classic DFFS › Count number of list items in a field
I would like to setup an alert message that tells me when a field has more or less than x number of items in a sorted or unsorted list
Example: Field = remainingTasks
In field there is a list of items present and I want to count how many list items (sorted or unsorted) are existing in that field when I enter the form
I tried these examples but could figure out how to properly adapt them to work:
//Counts the number of List Items in a field
/*
var theList = document.querySelector("[id*='remainingTasks_']");
alert(theList);
/*
var theList = document.getElementByRegex("^remainingTasks_.*").getElementsByTagName("ul");
var numberOfItems = theList.length;
alert(numberOfItems);
*/
Hi,
Is this a multiline rich text field where you want to count <li> elements?
If so, try this:
var html = jQspjs(getFieldValue("YourNoteFieldInternalName"));
var len = jQuery(html).find("li").length;
alert(len);
Replace YourNoteFieldInternalName with the internal name of your multiline field.
Alexander