Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ Issue with .innerHTML

Posted by: dkar_0029 Nov 17 2021, 01:40 PM

I want to replace the "No students enrolled" with the output from displayStudents(testArray) when it runs. I have attached the .js and .html files for reference.
Thanks!


Attached File(s)
Attached File  assignment_1a.zip ( 1.48k ) Number of downloads: 206

Posted by: Christian J Nov 17 2021, 03:12 PM

Seems to work for me. But the subject line of your forum topic is truncated, what is it meant to say?

Posted by: dkar_0029 Nov 17 2021, 03:21 PM

QUOTE(Christian J @ Nov 17 2021, 03:12 PM) *

Seems to work for me. But the subject line of your forum topic is truncated, what is it meant to say?

Wait, what, so there is no issue with my code? Interesting... been looking at it for a long time lol
Right, yes, the topic, let me show u instead.


Attached thumbnail(s)
Attached Image

Posted by: Christian J Nov 17 2021, 03:51 PM

Could it be due to

CODE
studentEnrolSummaryRef.innerHTML = displayStudents(studentList);

that uses the empty studentList array?

Posted by: dkar_0029 Nov 17 2021, 04:06 PM

QUOTE(Christian J @ Nov 17 2021, 03:51 PM) *

Could it be due to

CODE
studentEnrolSummaryRef.innerHTML = displayStudents(studentList);

that uses the empty studentList array?

Nope, I have been testing a simplified version that doesn't work either


Attached File(s)
Attached File  Simplified.zip ( 1.18k ) Number of downloads: 189

Posted by: dkar_0029 Nov 17 2021, 09:48 PM

QUOTE(Christian J @ Nov 17 2021, 03:12 PM) *

Seems to work for me. But the subject line of your forum topic is truncated, what is it meant to say?

Could u show me what it looks like for you when you run it?

Posted by: dkar_0029 Nov 18 2021, 12:28 AM

QUOTE(dkar_0029 @ Nov 17 2021, 04:06 PM) *

QUOTE(Christian J @ Nov 17 2021, 03:51 PM) *

Could it be due to

CODE
studentEnrolSummaryRef.innerHTML = displayStudents(studentList);

that uses the empty studentList array?

Nope, I have been testing a simplified version that doesn't work either


UPDATE - I FOUND IT!


Attached thumbnail(s)
Attached Image

Posted by: Brian Chandler Nov 18 2021, 01:08 AM

The answer is "debugging". Instead of staring endlessly at stuff trying to see the problem (which doesn't work), you put in debugging stuff. If the script file doesn't seem to be running, put "alert('fish');" near the beginning. You will immediately know when and whether it is being called.

Posted by: Christian J Nov 18 2021, 10:44 AM

QUOTE(dkar_0029 @ Nov 18 2021, 06:28 AM) *

UPDATE - I FOUND IT!

That doesn't explain the javascript errors though, a broken path to the JS file would prevent the script from running at all. I wouldn't worry about Scrimba though, use your web browsers' developer tools instead (both Firefox and Chromium-based).

And like Brian said, methodical debugging is the key...

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)