Jump to content
UBot Underground

Updating UI Dropdown


Recommended Posts

I'm trying to make 2 dropdowns. The first one will help populate the second one. For instance, the person would select a state in the first section and all of the cities would show up in the second dropdown.

 

The cities would have been user entered and saved to different files.

 

So what I have is the first dropdown pulls from a list of States. That works fine because this won't change. But the second dropdown doesn't change when a state is selected unless I switch tabs and go back. This isn't a viable solution when giving this to a client.

 

I tried having a button to press that would set a variable that's in the second dropdown but that has the same issue as well, I need t switch tabs and go back for it to show.

 

Does anyone have a solution for this or can think of a different way to do it?

 

The massive amount of variables doesn't make it ideal to just have one dropdown with all of the states/cities.

 

Any help is appreciated.

Link to post
Share on other sites

This works perfectly if you have the dev edition and use the UI HTML panel. If you don't then you could use this type of workaround which will work pretty well.

 

ui drop down("States", "Select,New York,New Jersey", #States)
ui button("Select City") {
   if($contains(#States, "New York")) {
       then {
           load html("<select variable=\"#Cities\" fillwith=\"value\" width=\"220px\"><option>New York City</option><option>Albany</option><option>Syracuse</option></select>")
       }
       else {
       }
   }
   if($contains(#States, "New Jersey")) {
       then {
           load html("<select variable=\"#Cities\" fillwith=\"value\" width=\"220px\"><option>Trenton</option><option>Newark</option><option>Atlantic City</option></select>")
       }
       else {
       }
   }
}

  • Like 1
Link to post
Share on other sites

That's pretty cool. The only thing is the dropdown doesn't change the variable. I select a city and the variable stays the same. Is there anyway to get that to work?

Link to post
Share on other sites

Yea sorry about that. If I wasn't so busy I'd do a mock script for you. Basically what you have to do is have the states variable call a specific optgroup. I'll try to do a mock up for you when I get a chance but the hint here is look into <optgroup></optgroup> to place the correct <option></option> menu for cities depending on states selection.

Link to post
Share on other sites

Yea sorry about that. If I wasn't so busy I'd do a mock script for you. Basically what you have to do is have the states variable call a specific optgroup. I'll try to do a mock up for you when I get a chance but the hint here is look into <optgroup></optgroup> to place the correct <option></option> menu for cities depending on states selection.

A mock script would be amazing. I'm looking into it until then. Thank you.

Link to post
Share on other sites
  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...