0

I'm getting an "Uncaught ReferenceError" on an onsubmit event in a form that has previously worked before splitting up my index.js into an additional js module. Tried a few different things that did not make a difference. Is there a way to solve this?

index.html

<form name="formFill" onsubmit="submitForm()" id="form">
   <button type="submit" id="calculate">Calculate</button>
   </form>

index.js

const submitForm = (event) => {
console.log('submitForm:', here)
const form = document.getElementById('form');
const data = new FormData(form);
const dataObject = {};
for (const [key, value] of data.entries()) {
dataObject[key] = value;
}
return dataObject; 
}
Reggie
  • 1
  • 1
  • Where’s the export? Where’s the import? Please see [Why are inline event handler attributes a bad idea in modern semantic HTML?](/q/11737873/4642212) and [ES6 Modules: Undefined onclick function after import](/q/44590393/4642212). – Sebastian Simon Nov 05 '22 at 03:40
  • export is in another file called calculations.js. in my index.js a the top importing each function separated by a comma from './calculations.js'. I didnt include all of is because there was a lot of fuctions – Reggie Nov 05 '22 at 12:17
  • How can the export statements be in another file? Does `index.js` export `submitForm` at all? If not, then the function is inaccessible. – Sebastian Simon Nov 05 '22 at 18:56

0 Answers0