How to set String variable to be text of clicked item

Hi,

Context
I am prototyping a table which contains the following labels:

  1. Name1
  2. Name2
  3. Name3

Desired behaviour
I want to be able to set a String variable to be the value of the text that I click. For example, if I click on Name1, the variable is set to be “Name1”.

Current approach
I have to set the click event per label and manually set the value to set the variable to. For example, upon click of the Name1 label, I have to manually set the string to be “Name1”.

Challenge
This is very manual. If I have a long list of names, and will have multiple tables in different screens, this will take more time than seems necessary.

Desired approach
I want to be able to create a generic prototype function that refers to the text value of the label rather than explicitly having to manually define the text string. For example, in programmatic terms, this function would be something like variable=clickedItem.text.

Question
Are we able to do this in Figma? For example, does Figma support use of a javascript (or other programmatic expressions) as can be done in Axure RP? If so, can someone provide a link to the documentation/video?

2 Likes