Dynamically Add Two Input Field When Button Click in React Js

  Рет қаралды 12,978

Coding Comics

Coding Comics

Күн бұрын

Dynamically Add Two Input Field When Button Click in React Js
To add two input fields when a button is clicked in React, you create a button that, when clicked, updates the state to include additional input fields. The state holds an array or list of input field configurations, and the component renders input fields based on this state. The button's click handler modifies the state to add new entries, which triggers a re-render to show the new input fields
code : github.com/Aka...
#react #addinputbuttonclick

Пікірлер: 28
@sanketgole4199
@sanketgole4199 Жыл бұрын
This type of videos really helpful for us bro to improve programming logic
@codingcomics
@codingcomics Жыл бұрын
Yes. Keep learn
@SatpalSingh-pz9xx
@SatpalSingh-pz9xx 5 ай бұрын
why clicking delete button deletes the last row of input fields?
@codingcomics
@codingcomics 5 ай бұрын
If you want to hide the delete button when you have only one field, then add this code. Check { data.length > 1 ? handleDelete(i)}>Delete : "" }
@SatpalSingh-pz9xx
@SatpalSingh-pz9xx 5 ай бұрын
@@codingcomics thank you for replying, you got one subscriber
@SatpalSingh-pz9xx
@SatpalSingh-pz9xx 5 ай бұрын
@@codingcomics actually the problem I am facing seems so wierd.... using add button I created three rows(each row contains input fields fname and lname) and I added values like a,b,c,d,e,f respectively in each input field. When I delete middle row then c,d should be deleted and a,b,e,f should remain. But in my case a,b,c,d remains and last row(e,f) gets deleted. When I checked the inputList value which is being mapped over after each render , after deleting the object list is like [{"fname": "a" , "lname": "b" },{"fname": "e" ,"lname": "f" }], which is correct, but why is it not being mapped over correctly after updating the list using setInputList()?
@codingcomics
@codingcomics 5 ай бұрын
I've provided the code link in the video description. Please compare that code to your code. If the issue isn't resolved, feel free to share your problem, and I'll do my best to help.
@shreyashukla4764
@shreyashukla4764 5 ай бұрын
@@SatpalSingh-pz9xx i am also facing same issue @codingcomics
@velioona9835
@velioona9835 Жыл бұрын
wow this man save my life, thank you mate
@roshanbhatt5853
@roshanbhatt5853 11 ай бұрын
Thanks for making this video but I have one more issue and that is what ever values we saved from this dynamically created control, I need to get it back and re populate into same control from db so how can I do it please help
@Vishalsaini-mn1nj
@Vishalsaini-mn1nj 8 ай бұрын
Thank you sir for helping us, definitely going to use this in my project 😊
@chuuuuuuuuucu
@chuuuuuuuuucu 9 ай бұрын
thank you very much for sharing
@jiaxin5230
@jiaxin5230 10 ай бұрын
thanks for your sharing
@RaviAdhav
@RaviAdhav 11 ай бұрын
very helpful thanks
@huywarrior
@huywarrior 8 ай бұрын
thanks! U're best!
@Infinitegameplay007
@Infinitegameplay007 11 ай бұрын
Thanx bro
@roshanbhatt5853
@roshanbhatt5853 Жыл бұрын
Thank you🎉
@ajimattar9101
@ajimattar9101 Жыл бұрын
Hi, How to limit number or rows and disable add button if rows are exceeded
@codingcomics
@codingcomics Жыл бұрын
1. initialize one state as zero. 2. inside add button increment the state value. 3. inside remove function decrement the state value. 4. inside button add like this =6}>add button will be disabled
@ananthakrishnankrishnan7287
@ananthakrishnankrishnan7287 Жыл бұрын
Thanks for this helpful video. I need the dynamic field to be react select combos, is it the same logic? How do I extract the data from combos into a json string to pass to server?
@codingcomics
@codingcomics Жыл бұрын
Yes. You can do same logic what I did. You will get array of object format
@ananthakrishnankrishnan7287
@ananthakrishnankrishnan7287 Жыл бұрын
@@codingcomics One last question, how do I load up the combo boxes with data from the server? How do I feed the object data to render the correct number of combo boxes depending on how many time add was clicked and data was added? Thanks for the help!
@ashvarygidian1996
@ashvarygidian1996 Жыл бұрын
Thank YOU .
@salaheldin9140
@salaheldin9140 Жыл бұрын
hello, sir can i contact you because i have a problem in the same project
@codingcomics
@codingcomics Жыл бұрын
Yes. Ping me in Instagram
@salaheldin9140
@salaheldin9140 Жыл бұрын
@@codingcomics i send to you a message
React: Add/Remove Input Fields Dynamically on button click
26:21
Chaoo Charles
Рет қаралды 81 М.
Dynamically Add Remove Multiple Input fields React JS
22:13
Devops Developer
Рет қаралды 35 М.
Крутой фокус + секрет! #shorts
00:10
Роман Magic
Рет қаралды 23 МЛН
🍉😋 #shorts
00:24
Денис Кукояка
Рет қаралды 3,6 МЛН
Create Dynamic Form Fields in React
28:14
Cand Dev
Рет қаралды 101 М.
React Reusable Component #5 Checkbox
13:12
Code With Ghazi
Рет қаралды 7 М.
Custom Context Menu / Custom Right Click Menu in React and NextJS Tutorial
10:43
Dynamic Add Remove Multiple Input Field With Validation In React Js
41:50
Seeema Holiday Developer
Рет қаралды 10 М.
React State Array of Objects
20:55
Sam Meech-Ward
Рет қаралды 26 М.
React Custom Hooks: useDebounce - Simply Explained!
10:38
Cosden Solutions
Рет қаралды 29 М.
React tutorial for beginners #15 Get Input box value
8:49
Code Step By Step
Рет қаралды 82 М.
Крутой фокус + секрет! #shorts
00:10
Роман Magic
Рет қаралды 23 МЛН