<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Dynamic Number boxes based on list items in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Dynamic-Number-boxes-based-on-list-items/m-p/785852#M96904</link>
    <description>&lt;P&gt;In the following script I have a list of 3 elements and I am trying to create a new window where the user can enter some values for each of the elements:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myList = {"apple", "banana", "orange"};

nw = New Window( "Enter Numbers",
    &amp;lt;&amp;lt;Modal,
    &amp;lt;&amp;lt;Return Result,
    V List Box(
		Text Box("Enter the values"),
        For( i = 1, i &amp;lt;= N Items( myList ), i++,
            Lineup Box( Text Box( Eval(myList[i])),
                Number Edit Box( 42 )
            )
        ),
        H List Box(
            Button Box( "OK" ),
            Button Box( "Cancel" )
        )
    )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I use the for loop because the number of the items in the list "myList" changes. So that I would like to happen also for the Number Edit Boxes. However, I get back the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Georgios_Tsim_0-1724768252918.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67570iD9F0C812C0FDFAEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Georgios_Tsim_0-1724768252918.png" alt="Georgios_Tsim_0-1724768252918.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Ideally I would like the values that the end user enters to be saved in a list.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Aug 2024 14:19:55 GMT</pubDate>
    <dc:creator>Georgios_Tsim</dc:creator>
    <dc:date>2024-08-27T14:19:55Z</dc:date>
    <item>
      <title>Dynamic Number boxes based on list items</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-Number-boxes-based-on-list-items/m-p/785852#M96904</link>
      <description>&lt;P&gt;In the following script I have a list of 3 elements and I am trying to create a new window where the user can enter some values for each of the elements:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myList = {"apple", "banana", "orange"};

nw = New Window( "Enter Numbers",
    &amp;lt;&amp;lt;Modal,
    &amp;lt;&amp;lt;Return Result,
    V List Box(
		Text Box("Enter the values"),
        For( i = 1, i &amp;lt;= N Items( myList ), i++,
            Lineup Box( Text Box( Eval(myList[i])),
                Number Edit Box( 42 )
            )
        ),
        H List Box(
            Button Box( "OK" ),
            Button Box( "Cancel" )
        )
    )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I use the for loop because the number of the items in the list "myList" changes. So that I would like to happen also for the Number Edit Boxes. However, I get back the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Georgios_Tsim_0-1724768252918.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67570iD9F0C812C0FDFAEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Georgios_Tsim_0-1724768252918.png" alt="Georgios_Tsim_0-1724768252918.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Ideally I would like the values that the end user enters to be saved in a list.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 14:19:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-Number-boxes-based-on-list-items/m-p/785852#M96904</guid>
      <dc:creator>Georgios_Tsim</dc:creator>
      <dc:date>2024-08-27T14:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Number boxes based on list items</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-Number-boxes-based-on-list-items/m-p/785888#M96905</link>
      <description>&lt;P&gt;Here is the approach that I would take&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
myList = {"apple", "banana", "orange"};

myVList = V List Box(
	Text Box( "Enter the values" ),
	lub = Lineup Box( N Col( 2 ), ),
	H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
);
For Each( {box}, myList,
	lub &amp;lt;&amp;lt; append( Text Box( Eval( box ) ) );
	lub &amp;lt;&amp;lt; append( Number Edit Box( 42 ) );
);
	
nw = New Window( "Enter Numbers",
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;Return Result,
	myVlist
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1724769101857.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67571i70B066AB4D35A5C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1724769101857.png" alt="txnelson_0-1724769101857.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 14:31:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-Number-boxes-based-on-list-items/m-p/785888#M96905</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-08-27T14:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Number boxes based on list items</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-Number-boxes-based-on-list-items/m-p/785937#M96906</link>
      <description>&lt;P&gt;Multiple different ways how you can do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use different methods of collecting the results, you can use XPath&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

fruits = {"apple", "banana", "orange"};

value_collector = V List Box(
	Text Box("Enter the values"),
	lub = Lineup Box(N Col(2))
);

For Each({fruit}, fruits,
	lub &amp;lt;&amp;lt; append(Text Box(fruit));
	lub &amp;lt;&amp;lt; append(Number Edit Box(42));
);

nw = New Window("Enter Numbers", &amp;lt;&amp;lt;Modal, &amp;lt;&amp;lt;Return Result, 
	V List Box(
		value_collector,
		H List Box(
			Button Box("OK",
				vals = (lub &amp;lt;&amp;lt; XPath("//NumberEditBox")) &amp;lt;&amp;lt; get;
			), 
			Button Box("Cancel")
		)
	)
);

If(nw["Button"] != 1,
	Throw("Cancelled")
);

Show(fruits, vals);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or store the references to a list&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

fruits = {"apple", "banana", "orange"};

value_collector = V List Box(
	Text Box("Enter the values"),
	lub = Lineup Box(N Col(2))
);

nebs = {};
For Each({fruit}, fruits,
	lub &amp;lt;&amp;lt; append(Text Box(fruit));
	lub &amp;lt;&amp;lt; append(neb = Number Edit Box(42));
	Insert Into(nebs, neb);
);

nw = New Window("Enter Numbers", &amp;lt;&amp;lt;Modal, &amp;lt;&amp;lt;Return Result, 
	V List Box(
		value_collector,
		H List Box(
			Button Box("OK",
				vals = nebs &amp;lt;&amp;lt; get;
			), 
			Button Box("Cancel")
		)
	)
);

If(nw["Button"] != 1,
	Throw("Cancelled")
);

Show(fruits, vals);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or associative array&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

fruits = {"apple", "banana", "orange"};

value_collector = V List Box(
	Text Box("Enter the values"),
	lub = Lineup Box(N Col(2))
);

vals = Associative Array();
For Each({fruit}, fruits,
	lub &amp;lt;&amp;lt; append(Text Box(fruit));
	lub &amp;lt;&amp;lt; append(neb = Number Edit Box(42));
	vals[fruit] = neb;
);

nw = New Window("Enter Numbers", &amp;lt;&amp;lt;Modal, &amp;lt;&amp;lt;Return Result, 
	V List Box(
		value_collector,
		H List Box(
			Button Box("OK",
				res = Associative Array(vals &amp;lt;&amp;lt; get keys, (vals &amp;lt;&amp;lt; get values) &amp;lt;&amp;lt; get);
			), 
			Button Box("Cancel")
		)
	)
);

If(nw["Button"] != 1,
	Throw("Cancelled")
);

Show(fruits, vals, res);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With these you will have UI something like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1724770118276.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67574i33AD25CCD1BE26A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1724770118276.png" alt="jthi_1-1724770118276.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Or you could utilize totally different display box elements (table box and number col edit box)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

fruits = {"apple", "banana", "orange"};

nw = New Window("Enter Numbers", &amp;lt;&amp;lt;Modal, &amp;lt;&amp;lt;Return Result, 
	V List Box(
		Text Box("Enter the values:"),
		Table Box(
			String Col Box("Fruit", fruits),
			nceb = Number Col Edit Box("Value", J(N Items(fruits), 1, 42)),
		),
		H List Box(
			Button Box("OK"), 
			Button Box("Cancel")
		)
	)
);

If(nw["Button"] != 1,
	Throw("Cancelled")
);

show(nw["nceb"]);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1724770072443.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67573i6DD519A3AA61CFB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1724770072443.png" alt="jthi_0-1724770072443.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 14:49:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-Number-boxes-based-on-list-items/m-p/785937#M96906</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-27T14:49:09Z</dc:date>
    </item>
  </channel>
</rss>

