0

Hi everybody I am trying to create a LWC that contains a Documents section like this one:

enter image description here

In the first part I have two inputs the left one called 'Type of document' and the other is 'URL Direction'. I want that every time the user clicks on the New button to create an other section like the two first inputs but below these ones. I mean I want them two repeat but with different name (e.x name='typeDocument1', name='typeDocument2'...).

I have the next code: enter image description here

<lightning-accordion-section name="Documentos" label="Documentos">
            <div class="slds-grid slds-grid slds-gutters">
                        <div class="lightningCardClass slds-col">
                            <lightning-input type="text" label="Tipo documento" max-length="2" required name="tipoDocumento1"></lightning-input>
                        </div>
                        <div class="lightningCardClass slds-col">
                            <lightning-input type="text" label="Direccion URL" max-length="255" required name="direccionURL1"></lightning-input>
                        </div>
                    </div>
                    
                </div>
            </div>
            <div class="lightningButton">
                <lightning-button label="Nuevo" class="slds-m-left_x-small" onclick={handleCreateOtherLine}></lightning-button>
            </div>
        </lightning-accordion-section>

That's something I am struggling and the other problem that I have is that do not know how would I be able to save the date from each one of the content the user inputed. Could anybody help me?

Thanks

1 Answer 1

1

Hope this will work for you. You can manipulate the data as your requirement

Demo

Ignore Cancel button

1
  • While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – identigral
    Nov 10, 2022 at 16:03

You must log in to answer this question.