Auto-filling radio buttons
Not sure if this is an appropriate forum to ask this question, but I've run out of options.
For a class, we have to take 300+ question tests, but we get to take them an infinite amount of times. I was wondering if there was a program that could intelligently save the status of r开发者_如何学运维adio buttons based on the questions asked so that I don't have to go through each question answering them one-by-one.
In case that wasn't clear: Each new time you take the test, it doesn't save what your answer was for the previous submission. I want a way that can auto-fill all the radio buttons based on the previous submission.
I tried an auto_fill extension, but those all of those worked based upon the javascript name of the button (which changes each time). Is there any solution?
Given what you've said this is the type of code I would start with.. Paste into the address bar of your browser on a page with radio buttons:
javascript:(function(){var inputElements = document.getElementsByTagName("input");for (var i=0; i<inputElements.length; i++) {if (inputElements[i].getAttribute('type') == 'radio') {inputElements[i].checked = true;}}})();
(readable version):
(function(){
var inputElements = document.getElementsByTagName("input");
for (var i=0; i<inputElements.length; i++) {
if (inputElements[i].getAttribute('type') == 'radio') {
inputElements[i].checked = true;
}
}
})();
This code sets every radio button to checked, but as only one radio button in each group can be selected, the actual result is that the last radio button in each group is selected. Not particularly useful, but I would probably need more details about the structure of the radio buttons (how many per question) to come up with anything better.
Taking it further, code could be written to run after you have filled in all the radio buttons once; this code would generate more code which would fill in the radio buttons for you subsequent times.
Of course, this is only a "sensible" solution to pursue if your school computers are "locked down" and you can't do much with them.
精彩评论