thanks for the help in this forum, I was able to get my code to work:
// ==UserScript==
// @name PARINGO
// @description Auto select rpt radio button
// @namespace PARINGO
// @include https://docs.google.com/spreadsheet/viewform?formkey=dG1fdUU1bTR5R1l3dmtGS095QVYxZlE6MQ
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant GM_addStyle
// @version 1
// ==/UserScript==
/*- The @grant directive is needed to work around a design change introduced
in GM 1.0. It restores the sandbox.
*/
//-- Note that :contains() is case-sensitive
var questionLabel = $(
"label.ss-q-title:contains('How much is 1+1') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=2]");
questionLabel.prop ('checked', true);
var questionLabel = $(
"label.ss-q-title:contains('How much is 4+2') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=6]");
questionLabel.prop ('checked', true);
What makes this script is to check the label and mark the correct answer. But if the response is composed of two or more separate words. No works e.g:
var questionLabel = $(
"label.ss-q-title:contains('How much is 4+2') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=dog crazy]");
questionLabel.prop ('checked', true);
This works for the form in google docs: Form Google Docs
Anybody can tell me how do that the value accept separate words?
("input[type=radio][value=dog crazy]")
Try putting the value in quotes
You are using jQuery's find method. Put the values in quotes:
There are examples like this in the jQuery documentation for Attributes in selectors. For example:
$('a[rel="nofollow self"]')
$("a[rel='nofollow self']")
Specifically, the docs state:
If an attribute consists of several words than you have to use quotes like this: