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
- :
- Create a dynamic dialog box depending on user-sele...

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

Jun 4, 2015 10:35 AM
(3110 views)

Hi all,

I'm trying to create a dynamic, modal window based on some user selections from a combo box. If the user selects option 1 from the combo box, I'd like to have a number edit box appear for the user to enter in a value. If the user selects option 2 from the combo box, I'd like to have two number edit boxes appear for the user to fill out.

I've made numerous attempts at trying to get the number boxes to appear and/or change depending on the combo box selection with no luck. I have posted one such attempt below. Any help would be greatly appreciated!

Thanks.

new Window("test",

modal,

x=Combo Box({"1","2"},

<< set function(function({this},

value = this << get;

//print(value);

return(value);

);

),

),

if(value == 3, H List Box(y = number edit box(.)));

if(value == 4,

H List Box(

y = number edit box(.),

y2 = number edit box(.),

)

)

);

1 ACCEPTED SOLUTION

Accepted Solutions

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

Jun 4, 2015 10:52 AM
(5732 views)

Solution

This one's a little tricky. I assume since "1" is the default that there will already be at least one number edit box.

new Window**(**"test",

<< **modal**,

x=Combo Box**({**"1","2"**}**,

value = x << **get selected**;

if **(**value == "2",

hlb << **append(**y2 = number edit box**(.))**,

value == "1",

y2 << **delete**;

**)**

**)**,

hlb = H List Box**(**

y1 = number edit box**(.)**,

**)**,

**)**;

4 REPLIES

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

Jun 4, 2015 10:52 AM
(5733 views)

This one's a little tricky. I assume since "1" is the default that there will already be at least one number edit box.

new Window**(**"test",

<< **modal**,

x=Combo Box**({**"1","2"**}**,

value = x << **get selected**;

if **(**value == "2",

hlb << **append(**y2 = number edit box**(.))**,

value == "1",

y2 << **delete**;

**)**

**)**,

hlb = H List Box**(**

y1 = number edit box**(.)**,

**)**,

**)**;

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

Jun 4, 2015 10:56 AM
(2866 views)

Hi PMroz,

I listed the more complicated scenarios here - there could be other options in the combo boxes where there's no number edit boxes needed at all.

Thanks.

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

Jun 4, 2015 11:22 AM
(2866 views)

Got a chance to play with this - this will work well - thanks so much!

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

Jun 4, 2015 11:03 AM
(2866 views)

The entire script needs to be within the combo box's function. Also, you have choices 1 and 2, but are comparing against a value of 3 or 4. Try this:

New Window**(** "test",

<<modal,

x = Combo Box**(** **{**"1", "2"**}**,

<<**set function****(** Function**(** **{**this**}**,

value = this << **get**;

If**(**

value == **1**,

Try**(** **(**this << **sib)** << **deletebox** **)**; // delete what might already exist

this << **sibappend(** H List Box**(** y = Number Edit Box**(** **.** **)** **)** **)**;, // add new box

value == **2**,

Try**(** **(**this << **sib)** << **deletebox** **)**; // delete what might already exist

this << **sibappend(** // add new box

H List Box**(**

y = Number Edit Box**(** **.** **)**,

y2 = Number Edit Box**(** **.** **)**

** )**

** )**;

** )**;

**)** **)**

** )**,

H List Box**(** y = Number Edit Box**(** **.** **)** **)** // since 1 is selected by default, put the box here initially

**)**;