How do I filter a textual dropdown using model data

Discussion in 'Website Development & Design' started by Boby Smith, May 17, 2013.

  1. Boby Smith

    Boby Smith
    uix_expand uix_collapse

    Dec 15, 2011
    Likes Received:
    Have a problem that I've been mulling over for a bit here - we have a dropdown box in our html/javascript (legacy, no JQuery yet) front end that displays a list of textual elements like so:

    Total capacity < 500ml
    Total capacity 500ml - 1L
    Total capacity 1L - 2L
    Total capacity > 2L

    In our Java model, we have the capacity of an item stored - so we know that CokeBottle is 600.00f capacity etc.

    My question is, without remodeling the dropdown objects to be more than just strings, how could I best automatically choose the correct capacity for an item when it is selected elsewhere? So that when the page is loaded for CokeBottle, it knows to choose "Total capacity 500ml - 1L" by default?

    Regular expressions would be one way of doing this, but it seems brittle and a bit confusing to maintain going forward.


    EDIT: I'm also happy to consider a filter approach - removing those items that dont qualify, as sometimes we will have up to twenty elements in these dropdowns - so anything we can do to reduce the manual work of a user will be welcome.

Share This Page