Dynamically Add and Remove Input Field when Button Clicked in React JS

Поделиться
HTML-код
  • Опубликовано: 15 янв 2025

Комментарии • 42

  • @SteadyFreedom
    @SteadyFreedom Год назад +2

    This is actually really cool. I was stuck trying to figure out a good way to delete an element from my list until I found this video. I did not know you could pass a unique identifier to a particular object of the map function. Thank you very much.

  • @Talgie228
    @Talgie228 2 года назад

    This is actually really great! It would be helpful if you also show how to add a text field with default information already inside it as well. But great video! I hope you continue making more!

  • @ashishkumar-fg7ph
    @ashishkumar-fg7ph Год назад

    thank you bhai bahut parasan kiya tha dynamic buttons me

  • @angularuser2104
    @angularuser2104 Год назад

    thank u so much nice and simple explanation :)

  • @viduscience8710
    @viduscience8710 6 месяцев назад

    Great
    Exactly what I needed

  • @julfinch
    @julfinch 2 года назад

    Thank you! This solved my problem.

  • @dsp_creations1217
    @dsp_creations1217 11 месяцев назад

    Hello i stuck with this can we connect some way . Many methods i tried still last index is deleting instead of selected index. Please revert

    • @codingcomics
      @codingcomics  11 месяцев назад

      I provided the GitHub link in the description. Take a look at the code.

  • @josephawe8398
    @josephawe8398 Год назад

    Awesome exatly what I needed

  • @sanketgole4199
    @sanketgole4199 Год назад +2

    Bro can you make this.
    Table
    1)Every table row has a checkbox.
    2) when you click on check box delete button will appear when you click on button hole row will delete
    3) delete all button also there on top of table.

    • @codingcomics
      @codingcomics  Год назад

      Yes. I will make video

    • @theaveragecarguy770
      @theaveragecarguy770 Год назад

      @@codingcomics maybe in the same video you could show how to handle multiple fields with multiple values to be added to array(array of objects)?

    • @codingcomics
      @codingcomics  Год назад +1

      Video link ruclips.net/video/-TJNe7DFLHY/видео.html

  • @dsp_creations1217
    @dsp_creations1217 11 месяцев назад

    const [formData, setFormData] = useState({
    sapno: "",
    sapimage: "",
    pits: [{ pitno: "", pitimages: [] ,url:''}],
    });
    with this being our form structure, the pit number and url are being deleted but the image of the last input index is being deleted and not respective to the pit number and url. please help us with this

    • @codingcomics
      @codingcomics  11 месяцев назад

      I think the correct index is passing for the pit number and url. The same index is not passing in the image. So maintain in a separate state and use the State.
      Maybe this will work

    • @dsp_creations1217
      @dsp_creations1217 11 месяцев назад

      ​@@codingcomics could you give your email id I will share actually what happening

  • @ianiketjain
    @ianiketjain Год назад

    Beautiful✨❤

  • @dr.slasher5346
    @dr.slasher5346 Год назад

    I had a small problem while returning the Input and button , I was map inside a label tag , what should have done is to map and return label with each input , the problem was so crazy ,that I couldn't delete the last element what ever I do
    , so keep in mind from such a silly bug

  • @ozsoytalha
    @ozsoytalha Год назад

    Thanks for your efforts. I have a question. In this structure how can I make the first line appear by default?

    • @codingcomics
      @codingcomics  Год назад

      const [val,setVal]=useState([' ']);
      add empty string in the useState

  • @SafiyullaMona
    @SafiyullaMona Год назад

    hello

    • @codingcomics
      @codingcomics  Год назад +1

      1.Initialize let val = 0 in one variable like this
      .2. Add condition inside add button
      If (val

    • @codingcomics
      @codingcomics  Год назад +1

      Try this

    • @SafiyullaMona
      @SafiyullaMona Год назад

      I can't use it to my code , thank you for the reply

    • @codingcomics
      @codingcomics  Год назад +1

      Why. Tell me the issue. I try to give solution

  • @dr.slasher5346
    @dr.slasher5346 Год назад

    great one ,
    but I got small bug , I can not delete the last input field

    • @dr.slasher5346
      @dr.slasher5346 Год назад

      it works fine now , I don't know why yesterday why it was behaving like this

  • @MrManumena
    @MrManumena Год назад

    Amazing 🔥

  • @jakubdrazkowski5952
    @jakubdrazkowski5952 Год назад

    How could I change the useState for Basic JavaScript?

    • @codingcomics
      @codingcomics  Год назад +1

      You can change Usestate to const value = []

    • @jakubdrazkowski5952
      @jakubdrazkowski5952 Год назад

      ​@@codingcomics Thanks ❤️ Subscribed and like

  • @AzizahAgha
    @AzizahAgha Год назад

    how can i edit the test on double click

    • @codingcomics
      @codingcomics  Год назад

      If you want to perform an edit, you need to set all the data in the setVal.

    • @AzizahAgha
      @AzizahAgha Год назад

      How can I do that... Can you send me an example... Or a video pls

  • @faruksardar8829
    @faruksardar8829 Год назад

    After refreshing the page all the input field getting removed, any solution for this, Thanks for this video BTW :)

    • @codingcomics
      @codingcomics  Год назад

      I will try and let you know

    • @faruksardar8829
      @faruksardar8829 Год назад

      @@codingcomics Thank you so much 🫡

    • @faruksardar8829
      @faruksardar8829 Год назад

      @Coding Comics I discovered a simple solution: by storing the input value in local storage, the input field will retain its value even after the page is refreshed. This method has worked for me.

    • @codingcomics
      @codingcomics  Год назад

      Yes.

    • @codingcomics
      @codingcomics  Год назад

      Thank you

  • @rijasm7200
    @rijasm7200 Год назад

    working thanks