0
Please I need help. The JavaScript code is meant to calculate the total cost of the service as the user clicks on the checkbox
5 Respuestas
+ 6
There are a few things required to fix your code. However, wouldn't it be better to have the calculation when the user clicks submit? Or what is the function of the button?
So you could save the function call until that click and I think many of your problems could be solved.
+ 3
Start with reading this. I think that might put you down the right path for you cart section update.
https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements
The other errors you can fix by adding an if(problemVariableName != null) before trying to get your value or comparing the value (for you discountCode, for exampl).
+ 2
Line 229: "const discountCode = document.querySelector('#discount-code').value;" is the cause of your initial typeError message. There is no HTMLElement with an id of "discount-code".
Take a closer look at line 167. There the id includes an underscore, not a dash.
And while you are looking at line 167 you need to remove the first id in line 167, it also is causing problems.
After you take care of the initial bugs you see there is a similar problem on line 236: "const cart = document.querySelector('#cart');"
+ 1
Thanks, I'll correct the errors. Hopefully that'll be the end of the errors.
0
True but I would have loved to have it display the prices live.
Do you have any recommendations?