Tips:Using JavaScript in Memento: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 29: Line 29:


=== Multiple-choice fields ===
=== Multiple-choice fields ===
The field() function returns an array of selected items from multiple-choice (Checkboxes & Multiple-choice list) fields. Therefore, if a comma-separated list of selections is desired for the result of a JavaScript field expression, it is necessary to fetch the items from the array and combine them into a string, separated by commas. This is easily done with the array method join().
The ''field()'' function returns an array of selected items from multiple-choice (Checkboxes & Multiple-choice list) fields. Therefore, if a comma-separated list of selections is desired for the result of a JavaScript field expression, it is necessary to fetch the items from the array and combine them into a string, separated by commas. This is easily done with the array method ''join()''.
==== Getting a comma-separated list of checked items from a multiple-choice field ====
==== Getting a comma-separated list of checked items from a multiple-choice field ====
{|
{|
Line 38: Line 38:
</source>
</source>
|}
|}
The same solution is needed for trigger scripts that want to use such a comma-separated string, such as for the set() method of the Entry object.
The same solution is needed for trigger scripts that want to use such a comma-separated string, such as for the ''set()'' method of the Entry object.
{|
{|
! Trigger script
! Trigger script