1

I have following two lines of code in template:

<lightning-button icon-name="utility:download"  onclick={handleExportAction} alternative-text="Export Data"></lightning-button>

<lightning-combobox name="sortOrder" value={value}  options={options} onchange={handleChange} style="width: 200px;margin-left:20px" ></lightning-combobox>

And two functions in Js File:

handleChange(event) {
      const select = event.detail.value;
}
handleExportAction(event) {
const select = event.detail.value;
}

I want value of combobox in handleExportAction function. How i can achieve this Please suggest me i am new lwc.Thanks

1

You can store the value in attribute named value which you defined on your template on onchange event so that you can use in your handleExportAction handler.

@track value = 'new';
    handleChange(event) {
            // Get the string of the "value" attribute on the selected option
            const selectedOption = event.detail.value;
            alert(`Option selected with value: ${selectedOption}`);
            this.value = event.detail.value;
        }
    }

You can use that variable as:-

handleExportAction(event) {
const select = this.value;
}
1
  • Thanks a lot Bro! You Save me.tnx – Satish May 31 '19 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.