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

  Рет қаралды 44,718

Coding Comics

Coding Comics

2 жыл бұрын

How to add and remove input dynamically when button is clicked and console the value in react js.
source code : ( github.com/AkajithAk/youtubeR... )
#react #dynamicinput #addRemoveDynamicInputButtonClick

Пікірлер: 41
@supernico374
@supernico374 Жыл бұрын
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 Жыл бұрын
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!
@josephawe8398
@josephawe8398 Жыл бұрын
Awesome exatly what I needed
@julfinch
@julfinch Жыл бұрын
Thank you! This solved my problem.
@angularuser2104
@angularuser2104 11 ай бұрын
thank u so much nice and simple explanation :)
@ashishkumar-fg7ph
@ashishkumar-fg7ph Жыл бұрын
thank you bhai bahut parasan kiya tha dynamic buttons me
@codingcomics
@codingcomics Жыл бұрын
I will try and let you know
@MrManumena
@MrManumena Жыл бұрын
Amazing 🔥
@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
@aniketjain6886
@aniketjain6886 Жыл бұрын
Beautiful✨❤
@rijasm7200
@rijasm7200 Жыл бұрын
working thanks
@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
@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
@dsp_creations1217
@dsp_creations1217 5 ай бұрын
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 5 ай бұрын
I provided the GitHub link in the description. Take a look at the code.
@dsp_creations1217
@dsp_creations1217 5 ай бұрын
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 5 ай бұрын
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 5 ай бұрын
​@@codingcomics could you give your email id I will share actually what happening
@sanketgole4199
@sanketgole4199 Жыл бұрын
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 Жыл бұрын
Video link kzbin.info/www/bejne/Y4Wtf5hteat_frs
@jakubdrazkowski5952
@jakubdrazkowski5952 Жыл бұрын
How could I change the useState for Basic JavaScript?
@codingcomics
@codingcomics Жыл бұрын
You can change Usestate to const value = []
@jakubdrazkowski5952
@jakubdrazkowski5952 Жыл бұрын
​@@codingcomics Thanks ❤️ Subscribed and like
@user-ft9cg5ro1d
@user-ft9cg5ro1d 9 ай бұрын
how can i edit the test on double click
@codingcomics
@codingcomics 9 ай бұрын
If you want to perform an edit, you need to set all the data in the setVal.
@user-ft9cg5ro1d
@user-ft9cg5ro1d 9 ай бұрын
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
@SafiyullaMona
@SafiyullaMona Жыл бұрын
hello
@codingcomics
@codingcomics Жыл бұрын
1.Initialize let val = 0 in one variable like this .2. Add condition inside add button If (val
@codingcomics
@codingcomics Жыл бұрын
Try this
@SafiyullaMona
@SafiyullaMona Жыл бұрын
I can't use it to my code , thank you for the reply
@codingcomics
@codingcomics Жыл бұрын
Why. Tell me the issue. I try to give solution
React: Add/Remove Input Fields Dynamically on button click
26:21
Chaoo Charles
Рет қаралды 78 М.
Dynamically Add Remove Multiple Input fields React JS
22:13
Devops Developer
Рет қаралды 34 М.
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 63 МЛН
Linux on Windows......Windows on Linux
23:54
NetworkChuck
Рет қаралды 178 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
Click Outside to Close - React Hook
6:37
TK
Рет қаралды 59 М.
Dynamically Add Two Input Field When Button Click in React Js
8:32
Coding Comics
Рет қаралды 11 М.
Create Dynamic Form Fields in React
28:14
Cand Dev
Рет қаралды 100 М.
React Hook Form Tutorial - 15 - Dynamic Fields
9:35
Codevolution
Рет қаралды 60 М.
This React UI Library is GAME CHANGER!
18:13
developedbyed
Рет қаралды 517 М.