Adding multiple items to a list using a single entry box with an "Add Item" button

Mar 26, 2018

Hi there,

I'm trying to figure out how to add multiple items to a list using a single text entry box (actually an essay question box, as it allows me to control the character count) and an "Add Item to List" button. The problem is I can't figure out a way to control the variable count, since the text entry allows you to press "Enter" to add to the list, or click the "Add Item" button.

Currently, whatever the user types into the text box is assigned to TextEntry1. I can then print TextEntry1 to the list on the screen. Where it gets complicated is when I now want the next thing they type in the text box to be assigned to TextEntry2. 

I tried setting up a counter variable that increases by 1 everytime the button is clicked. If the button is clicked and Var_counter = 2, then set the text entry= TextEntry2. Seems simple, however when I click "Enter" instead of the "Add" button, the value of the counter returns NAN. I then click the "Add" button and the value of the counter is reset to 1. 

The other problem is I can only assign one variable to the text entry box when control loses focus.

Is there an easier way to do this?

4 Replies
John DePauw

For the benefit of anyone else with the same problem. I changed my logic. Instead of tracking "Enter" and "Add Item", I had the counter variable change whenever the textbox variable changed (essentially whenever I type something new in the textbox it adds +1 to the counter) I then display var1, 2, 3, 4 etc based on whatever the counter is set to.

This discussion is closed. You can start a new discussion or contact Articulate Support.