[React]Need some help to solve my functionality bugs[SOLVED]

Hi everyone,

I have to make a functionality which when a checkbox below an input is checked this specific input become red.

Until now I success in making a functionality which make an input red when new inputs aren’t added. So now, I have to make it work when new inputs are added. I success at making new inputs red but I have some bugs with my functionality :

  • I have a problem with the emptyQuestions array id which stay the same when a new input is added
  • when my render is loaded for the first time, I only need to have three question inputs with a checkbox below each one of them
  • only the specific input above the checkox need to become red when the checkbox in question is checked

Here is my code : https://codesandbox.io/s/v846xp5yxy

Thank you everyone who kindly read my post until now. I would be very glad if someone could give me some advice to help me solved these bugs.:blush:

So just to confirm, when marking the checkbox you want to highlight in red the text box below it? Right now any checkbox is apparently marking as red the same three text boxes. Which to me it all looks like its ID or Key duplicity in this case, but confirm me the behaviour and i’ll have a look to see if i can help.

If you only have three questions in your array, i would expect to see at 3 checkboxes and text boxes if i understood correctly. But maybe there is something i’m not getting.

Regards.

Thank you for your reply. :blush:

In fact, I want to highlight in red the text box above the checkbox.
Yes, I think there is a problem with id or key duplicity too.

Yes, you need to see 3 textboxes and 3 checkboxes.

Thanks to @Eldhose I solved my problem (and it’s even more simple than the code he shows me :sweat_smile: ). :partying_face:

Sometimes, I am really wondering why I always complicate things unconsciously…:face_with_raised_eyebrow:

just see the link again , i updated that

you can enter anything, when you click on preview button you can see what you enter into inputfield and a submit butoon. if you click on the submit butoon, you can see the the ouput on your browser console.
but when you click on submit button , this function savaTODataBase will get invoked, inside that you can write your post request your server

Thank you for your reply but I already solved my problem.:wink: So this thread is close. But thanks anyway.

1 Like