1

I'm trying to scrape my university's student website page for my grades and schedule.

I can login fine and I get to this point here but this dropdown is giving me so many issues. The way it works normally is the user selects an item in the dropdown, then presses a button next to it to submit.

Now, I've tried setting it by doing this:

document.getElementById(selectId).value = valueIWant

and

document.getElementById(selectId).selectedIndex = indexIWant

which both work, they change the value that is displayed in the select element, however, if I click the button next to it now, or call a click() on the button, it just resets to it's original value and doesn't load the page I want. But if I select the value with my mouse everything works fine... I don't get it, and I don't know what I'm doing wrong.

Has anyone come across something like this before? I appreciate any help you guys can provide :)

AndrewL64
  • 15,794
  • 8
  • 47
  • 79
Adam
  • 63
  • 8
  • More than likely the drop down has an event associated with the value changing, you would need to trigger the change event of the drop down before causing the button click. Here is a stack overflow post about how to trigger the change event with plain javascript (https://stackoverflow.com/questions/19329978/change-selects-option-and-trigger-events-with-javascript) – Ryan Wilson May 16 '18 at 19:57
  • @RyanWilson thank you so much! That issue was killing me! :) – Adam May 16 '18 at 20:12
  • You're welcome. Did that solve the issue? – Ryan Wilson May 16 '18 at 20:13
  • @RyanWilson Yep! – Adam May 16 '18 at 20:14
  • Good job Adam. I'm giving your answer a +1. – Ryan Wilson May 16 '18 at 20:15

1 Answers1

1

All I had to do was add a mySelect.onchange() before calling the button click.

Adam
  • 63
  • 8