Skip to content
Advertisement

Page refreshes on subsequent submits

I’ve been trying to submit a file (image) and a quiz in a form. They both have separate buttons but the file button must be pressed first for the image path to be added to the question post data state.

However, for some reason, the page refreshes after the 2nd or 3rd image upload. This only occurs when uploading the file.

JavaScript
JavaScript

Advertisement

Answer

swapping the onClick to the handle function and having the onSubmit call e.preventDefault() fixed my issue of having multiple forms on a page and random refreshes after submitting different forms in succession.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement