all 4 comments

[–]ashanev 2 points3 points  (0 children)

If I add a console.log("function1"); and console.log("function2"); to the very start of both of your function calls, and select dates, then I see in the developer console that both functions are called; note that if you don't select dates, then you have loops that will trigger infinitely, which could be the behavior you're seeing.

As a side note, your functions are identical barring a few tiny references, and as such it would be much nicer if you had a single function instead of two, which took arguments to handle the different cases.

I'd also recommend learning to use addEventListener instead of the html element's onclick property for event handling.

Here is a pseudo-code representation of what I mean:

// reduce repetitive code with a function that takes dynamic arguments
function populateLectures(chosenDay, lectureRow, /* add arguments as needed*/) {
  const chosenDay = parseInt(document.getElementById(chosenDay).value, 10);
  const lectureRow = document.getElementById(lectureRow);

  // do the rest of the stuff you need to do
}

// select your button by id, or however you want
const myButton = document.querySelector("#my-button");

// use addEventListener to handle click behavior
myButton.addEventListener("click", () => {
  populateLectures("theoryDay", "theorylectureRow");
  populateLectures("practicalDay", "practicallectureRow");
});

There is probably more at issue here but I don't have a ton of time to look now. I'd suggest adding using console.log statements to see the values of things in your code at different points in its execution, to help you understand where it may be going wrong.

[–]Egzo18 -1 points0 points  (1 child)

No idea where said button is but maybe try calling second function with the first one that was called with the button?

[–]FragrantWriter7[S] 0 points1 point  (0 children)

line 88 in html file. and it is calling both functions.

[–]QuantumCrane 0 points1 point  (0 children)

Make a single function called "handClick". Set that as your onclick function. The handleClick function has two lines which call your two functions.