0

enter image description hereI created an LWC in which I have 3 parts on a page: (here Allergy & Medication are visible). 1st page has 2 input fields, and to view each part of the page, a boolean variable is used (template isTrue for each part).

When I go to Medications part of the page, & then get back to Allergy part, the user input is not visible. The value exists in the array (as visible in console.log(arrayName)), but it is not displayed on the screen anymore.

HTML Code: -

<template if:true={displayAllergyInputPart}>
<lightning-input
              style="display: inline"
              name="Subtance__c"
              max-length="40"
            >
        </lightning-input>
            <br />
            <label for="Reaction__c">What does it feel? </label>                
<lightning-textarea
              name="Reaction__c"
              max-length="255"
              style="display:inline"
            ></lightning-textarea>
</template>

JavaScript Code: -

enableAllergySection(){
    this.displayAllergyInputPart= true;
}

1 Answer 1

1

I believe you are looking for some kind of Wizard UI whenever you will back to the previous Section, you are looking to prefill those selected values. Root Cause: You are missing value in lightning-input & lightning-textarea Please update your HTML & .js with value example code.

<template if:true={displayAllergyInputPart}>
<lightning-input
          style="display: inline"
          name="Subtance__c"
          max-length="40"
          value={inputFieldValue}
        >
</lightning-input>
<br />    
<label for="Reaction__c">What does it feel? </label>                
<lightning-textarea
          name="Reaction__c"
          max-length="255"
          style="display:inline"
          value={inputTextAreaValue}
          >
</lightning-textarea>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .