jQWidgets Forums

jQuery UI Widgets Forums Lists ComboBox Getting the value of the comboBox not at the selected index

This topic contains 1 reply, has 1 voice, and was last updated by  bsetz 8 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • bsetz
    Participant

    Hi,

    I’ve run into this edge case with the combo box where I need to get the text entered into the box that is not in the predefined list. Let’s say the list contains “lime green”, but I want to allow the user to input “lime”, which is not in the predefined list. When typing into the box, it will auto select the index for “lime green”. When I call $(‘#myComboBox’).val(), it will get the value of the selected index, grabbing whatever I have set as the value member for “lime green”, instead of it using the jQuery functionality and retrieving the text within the box. This issue does not arise if I enter in a value that cannot be auto-completed to an item within the list, because then the selected index will be -1 and calling .val() will utilize jQuery’s functionality, and retrieve the text entered.

    How can I make sure that I am getting the text inside the box and not the value of the item in the combo box?

    Thanks,


    bsetz
    Participant

    Found a solution, because the combobox html properties are built dynamically, there is no unique id for the input box to grab the text from. So instead I dive into all the div’s that get generated beneath my combobox $(‘#myComboBox’). The input tag is under one 3 layers of div, so calling $(‘#dropdownlistContentmyComboBox‘).val() will always retrieve the text inside the combo box. I believe the dropdownlistContent is always static, and what follows is the unique ID for the combo box.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.