#Need Help with a project

26 messages · Page 1 of 1 (latest)

sour timber
#

Hello ive been doing this final prject for my prgramming class and cannot seem to get the order summary to pop up on the order form page. if i could get some help that would be amazing.
https://pastebin.com/GZqNFntN

exotic briar
#

first, you need to be generating summary in the event handler. right now it's only ever being generated once

#

what do you mean you can't get it to pop up? what is the current behavior?

sour timber
exotic briar
#

oh, you have syntax error(s)

#

you didn't close out a block (missing }); at the end of your script)

sour timber
#

okay, ive been using brackets bc thats the editor the class uses

exotic briar
#

never used it, but if it didn't show an error it's garbage 😉 I'll admit this error would have been hard to notice because you're using inline script tags. one of many reasons not to.

#

innerHTML is also bad

sour timber
#

am i missing a closing bracket on the Const summary

exotic briar
#

the entire event handler

#

the other end of this:

form.addEventListener('submit', (event) => {
sour timber
#

and the inner html?

exotic briar
#
  1. you are setting innerHTML before summary has been defined. so it's not going to work.
  2. generally innerHTML is bad. it's better to use HTML templates and/or document.createElement() and .textContent
sour timber
#

weve been using inner html the entire class for some reason i mean it is a beginner level programming class

#

so define summary first then set the inner html of the summary

exotic briar
#

JS teachers are terrible and it makes teaching some things easier. just know that it's dangerous

sour timber
#

Noted.

#

still getting the same error. its gotta be something else. https://pastebin.com/5x39QUTD i put the const summary before the event listener and closed the bracket

#

if it would help to get some context i can send you the zip file if you dont mind

exotic briar
#

you gotta open up devtools and read the errors

Uncaught SyntaxError: missing ) after argument list (
exotic briar
#

you also moved the definition of summary to the wrong place... it needs to be inside the event listener and after you calculate all of the values used inside of it...

#

the definition of summary was actually fine where it was. you were just assigning it to the innerHTML of an element in the wrong place.