Displaying selected data from listbox in textbox

Posted by: nivishapanwar on 19 January 2021, 7:21 pm EST

    • Post Options:
    • Link

    Posted 19 January 2021, 7:21 pm EST

    Hello,

    I am using wijmo listbox .

    How can I show the selected record from wijmo listbox in another textbox,like directly after selecting a record from a list of records in listbox it should be displayed in the textbox.

    Thank you.

    Regards,

    Nivisha

  • Posted 20 January 2021, 10:43 pm EST

    Hi Nivisha,

    You may handle the selectedIndexChanged event and update the value of the text field with the currently selected value. Please refer to the following code snippet and the sample demonstrating the same:

    var lb = new wjInput.ListBox(listHost, {
      itemsSource: getCoutries(),
      selectedIndexChanged: (s, e) => {
        displayListBoxValueInTextField(s);
      }
    });
    // initial display
    displayListBoxValueInTextField(lb);
    
    function displayListBoxValueInTextField(listBox) {
      let tb = document.getElementById("inp");
      tb.value = listBox.selectedValue;
    }
    

    https://codesandbox.io/s/wijmo-starter-forked-po59j?file=/src/index.js

    Regards

    Sharad

  • Posted 22 January 2021, 2:39 am EST

    Hi Sharad,

    Thank you, it worked as expected.

    Regards,

    Nivisha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels