Skip to content

Instantly share code, notes, and snippets.

@ashkantaravati
Last active June 11, 2019 05:50
Show Gist options
  • Save ashkantaravati/59e2f0d1ed6536bb44c19580e414efe3 to your computer and use it in GitHub Desktop.
Save ashkantaravati/59e2f0d1ed6536bb44c19580e414efe3 to your computer and use it in GitHub Desktop.
I was too lazy and tired to answer all the professor survey questions so I wrote this!
var matches = [].slice.call(document.querySelectorAll('[id^=DropDownList]'));//Gets all dropdown selectors in an array
for (var i=0;i<matches.length;i++){//iterate through dropdownlists
//** random number generator part
var min = Math.ceil(2);
var max = Math.floor(6);
var randscore=Math.floor(Math.random() * (max - min)) + min;
//** random number generator part ends
matches[i].selectedIndex=randscore.toString();// set scores
}//we're done
@ashkantaravati
Copy link
Author

just works on a single page using console.
it could be better if it could iterate through surveys, set answers, submit and voila!
Please Contribute ^_^

@rezkam
Copy link

rezkam commented Jun 17, 2018

Dude ishalaw aroosit ❤️

@Mahmoud-Sagharjoughi
Copy link

var matches = [].slice.call(document.querySelectorAll('[id^=DropDownList]'));//Gets all dropdown selectors in an array
for (var i=0;i<matches.length;i++){//iterate through dropdownlists
//** random number generator part
var min = Math.ceil(1);
var max = Math.floor(5);
var randscore=Math.floor(Math.random() * (max - min)) + min;
//** random number generator part ends
matches[i].selectedIndex=randscore.toString();// set scores
}//we're done

To answer all questions

Copy the updated above code

Changes:

  • change min from 2 to 1
  • and max from 6 to 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment