turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- How to use Number Edit Box new value

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 7, 2017 8:01 AM
(832 views)

Hello everyone! I feel like such a novice today. I cannot seem to find clear information on how to have Number Edit Box values update a Window, other Number Edit Boxes, and equations when values are changed. My biggest issue is that I have over 30 Number Edit Boxes that feed 2 equations/formulas. Setting the starting values, I have down. If a value is changed, everything else needs to update and I can't figure out what I'm missing and online research has led me no further than when I started.

I have created a small, simple script in hopes of someone here can help me get this understanding through my thick skull.

Thank you all in advance for your knowledge and patience!

```
doTheMath = function({ val1, val2},
{result},
( val1 * val2 )
);
var1 = 0;
var2 = 0;
nw = new window( " Testing ",
<< modal,
testingVLB = V List Box(
enterValues = H List Box(
tbBox1 = Text Box( " Enter Value 1" ),
nebBox1 = Number Edit Box(var1),
tbBox2 = Text Box( " Enter Value 2" ),
nebBox2 = Number Edit Box(var2),
var1 = nebBox1 << get,
var2 = nebBox2 << get,
),
testResult = doTheMath( var1 , var2),
tbNothing = Text Box(""),
if(all(var1!=0, var2!=0), tbResult = Text Box( " Your Result is: " || char( var1 ) || "x" || char( var2 )|| "=" || char( testResult ) ))
);
);
```

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 7, 2017 8:35 AM
(1651 views)

Solution

Try this code. You have to use the << set function() construct for number edit boxes.

```
doTheMath = function({ val1, val2},
{result},
( val1 * val2 )
);
var1 = 0;
var2 = 0;
// Save the callback steps as an expression because they're the same for both number edit boxes
num_expr = expr(
var1 = nebBox1 << get;
var2 = nebBox2 << get;
if (!isempty(var1) & !isempty(var2),
testResult = doTheMath( var1 , var2);
tbResult << set text(char(testresult));
);
);
nw = new window( "Testing ", << modal,
testingVLB = V List Box(
enterValues = H List Box(
tbBox1 = Text Box( " Enter Value 1" ),
nebBox1 = Number Edit Box(var1, 10, << set function(num_expr)),
tbBox2 = Text Box( " Enter Value 2" ),
nebBox2 = Number Edit Box(var2, 10, << set function(num_expr)
),
),
tbresult = text box(""),
),
);
```

4 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 7, 2017 8:35 AM
(1652 views)

Try this code. You have to use the << set function() construct for number edit boxes.

```
doTheMath = function({ val1, val2},
{result},
( val1 * val2 )
);
var1 = 0;
var2 = 0;
// Save the callback steps as an expression because they're the same for both number edit boxes
num_expr = expr(
var1 = nebBox1 << get;
var2 = nebBox2 << get;
if (!isempty(var1) & !isempty(var2),
testResult = doTheMath( var1 , var2);
tbResult << set text(char(testresult));
);
);
nw = new window( "Testing ", << modal,
testingVLB = V List Box(
enterValues = H List Box(
tbBox1 = Text Box( " Enter Value 1" ),
nebBox1 = Number Edit Box(var1, 10, << set function(num_expr)),
tbBox2 = Text Box( " Enter Value 2" ),
nebBox2 = Number Edit Box(var2, 10, << set function(num_expr)
),
),
tbresult = text box(""),
),
);
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 7, 2017 9:14 AM
(821 views)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 7, 2017 10:01 AM
(816 views)

You might want to research the Number Edit Col Box object if you have that many related numeric inputs.

Learn it once, use it forever!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 7, 2017 10:41 AM
(808 views)