Using forms in Codepen

I’m working on a simple project to practice Javascript. I want to make a reset button. It appears that Codepen won’t let you use the <form> tag to simply make a reset button. I tried to use some Javascript:

function reset() { document.getElementById("reset").reset();}

Does the Javascript need the form tag, too? Is there a way to use forms in Codepen?

Thank you!

Reset works fine??

As @DanCouper showed reset works so you need to show more code to reveal the problem.

Thanks for helping. The game works fine with no form tags. But if I use form tags, it stops working and I get a bad path error message.

Edit to fix link

We need to see the code. I assume you have an HTML typo on one of the buttons and they try to submit the form, but it’s impossible to tell. Also are you literally just trying to put the value of the select back to the first value?

  1. You don’t have a button type=“reset” nested in a form element. As @DanCouper showed you don’t need JavaScript to reset a form.

  2. If you want to reset the form (which you don’t have) with JavaScript you would need to add an event listener to that id in your JavaScript.


I removed the form element because as soon as I added <form></form> , the game stopped working. When I hit the button to see who won, I get a “boomboom” error message from Codepen.

The <input type="reset"> defines a reset button which resets all form values to its initial values.

Your buttons do not have values. Even if they did, it seems you are trying to reset the innerHTML of your button. You can do that with JavaScript.