+ 1
Why is the age variable undefined?
16 odpowiedzi
+ 8
Hi Ilia Zandi I'm getting the error here on my phone and on my computer.
There are many syntax errors, starting from the head tag where you have a h1 tag inside of it. And the whole html and js code is very messy, it can confuse browsers and make them behave weird 😜
But the main issue is:
》Only the first input of the breakfast selection is being targetted in your JS in your input variable so the result is always going to be the same. Since all the breakfast inputs are checkboxes it has to be treated as an array and can be targetted via getElementsByName. Also the js logic has to be exactly the same as the Sides's logic, which is also an array because it has multiple checkbox options.
I'm attaching your code revised. It took me some time because I had to reorganize it. I'll leave you the homework of adding label tags in the form for the Side Options and Age, I did it for the Breakfast selection so you can take it as a guide. Hope it helps you 👍
https://code.sololearn.com/WFxLrbH3IRp8/?ref=app
+ 4
It's working fine for me.
+ 4
Ilia Zandi whoops! sorry, it's attached now 😊 also I forgot to mention that I have used a different way for targetting the radio inputs to avoid getting an 'undefined menu'. If you have any question let me know 👍😊
+ 3
works fine here
+ 2
Same here too..working alright
+ 1
But when you run the code in the second line it says from the undefind menu why does it say undefined instead of the age of the user.
+ 1
Tried all combinations but didnt got that error...can u send a screenshot
+ 1
Just hit the submit button and it says: you ordered the cereal with coffee as sides from the *Undefinedmenu*.Your order will be ready in under 7 minutes. What is undefined :(
+ 1
Thank you!! but the there is nothing in the link
0
it wroks but in the output it says : you ordered the cereal with coffee as sides from the *Undefinedmenu*.Your order will be ready in under 7 minutes
0
that's weird
https://imgur.com/gallery/IGjDB2r
0
omg! when I go with my phone it works but not with it doesn't work on my pc
0
ohhh something funny.
when I open it in firefox it works but not in internet explorer
0
yea..now that's weird....sorry but can help in it nos cuz i am not on pc right now .....i'll try it when i am pc..hope your problem get solved soon
0
it works on Firefox so it's all good