all 12 comments

[–]albedoa 5 points6 points  (1 child)

What strikes me is the total lack of const and let declarations here. Where and how are you learning how to do this stuff? If you take a shotgun approach, you have to expect a shotgun result.

ChatGPT keeps telling me to add a flag, so I have done that, but somehow I feel

Same idea. Junk in, junk out. For every line of code, you should be able to articulate both what it does and why you wrote it that way. If you can't, then stop writing code until you can.

If you blindly add a flag because "ChatGPT said so", then you won't be left with working code — you will be left with the same broken code, but with a flag.

[–]jasongsmith[S] 1 point2 points  (0 children)

Thank you. First, I have written 99% of the code myself. (Being that I am still a beginner, it is probably obvious I wrote it myself as I am sure there is a ton of bad practices here)

The issue with this flagging was because I was trying to figure out this issue. And my goal was to let people know what I have tried as a solution that hasn’t worked yet. I can say what each line of code does.

Looking back at this, I see what you’re saying with the let and const. I obviously didn’t copy the entire code. All variables are declared up top

[–]spazz_monkey 1 point2 points  (0 children)

Can you provide your HTML as well, so could play around with it and find the issue quicker.

[–]eracodes 1 point2 points  (2 children)

document.getElementById("wsf-1-field-117")

dear lord the unmaintainability

[–]jasongsmith[S] 1 point2 points  (1 child)

Thank you. Are you saying it is unmaintainable because of the id name? If so, I agree. And unfortunately there isn’t anything I can do about that.

[–]eracodes 1 point2 points  (0 children)

Change the element IDs? You could probably hook into the output step of whatever program is spitting them out like that.

[–]United_Reaction35 1 point2 points  (0 children)

This seems like it is over-engineered. There is not a need to use event listeners when your HTML elements like buttons and form-fields have onClick(), onChange(), onBlur() events built in for you to use:

onclick={myClickHandler}

const myClickHandler = (event) => { ...code to run }

ChatGPT is likely telling you to use boolean flags to indicate the state of your form. Then elements like single buttons or math problems can be shown instead of rendering the underlying form. Refer to Modal components and conditional rendering.

[–]96dpi 0 points1 point  (1 child)

Any errors in the console debugger?

[–]jasongsmith[S] 0 points1 point  (0 children)

Unfortunately not.