Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8813633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:54:18+00:00 2026-06-14T03:54:18+00:00

I need help… I want to click a radio button automatically…but also need to

  • 0

I need help…
I want to click a radio button automatically…but also need to check the sentence (label)…
eg…() <-radio button

<label>How much is 1+1?</label><br/>
<input type="radio" name="group1" value="2"/>()2<br/>
<input type="radio" name="group1" value="3"/>()3<br/>
<input type="radio" name="group1" value="4"/>()4

I tried use this script:

// ==UserScript==
// @name script
// @description Auto select rpt radio button
// @include *
// ==/UserScript==

if(radio=document.evaluate('//input[@type="radio" and @value="2"]',document,null,9,null).singleNodeValue)
radio.checked=true;

Ok, this code..click answer ()2
but what happen if i have the following:

<label>How much is 1+1?</label><br/>
<input type="radio" name="group1" value="2"/>()2<br/>
<input type="radio" name="group1" value="3"/>()3<br/>
<input type="radio" name="group1" value="4"/>()4

How much is 4+2?<br/>
<input type="radio" name="group1" value="8"/>()8<br/>
<input type="radio" name="group1" value="2"/>()2<br/>
<input type="radio" name="group1" value="6"/>()6

Nothing happens because there are two values ​​called “2”..so I tried to modify the code to first check the sentence and then mark the answer (but I have not mastered it very well)…

if(label=document.evaluate('//label[@value="How much is 1+1?"]',document,null,9,null).singleNodeValue)&&(radio=document.evaluate('//input[@type="radio" and @value="2"]',document,null,9,null).singleNodeValue)
radio.checked=true;

My intention was to add a second condition that check the labels with values ​​containing “How much is 1+1?”

Could anyone guide me on how to do that?

Edit:
The sample link:
Google docs form

The page code looks something like this:
Label:

<label class="ss-q-title" for="entry_0">How much is 1+1
<span class="ss-required-asterisk">*</span></label>

Radios:

<ul class="ss-choices"><li class="ss-choice-item"><label class="ss-choice-label"><input name="entry.0.group" value="2" class="ss-q-radio" id="group_0_1" type="radio">
2</label></li> <li class="ss-choice-item"><label class="ss-choice-label"><input name="entry.0.group" value="3" class="ss-q-radio" id="group_0_2" type="radio">
3</label></li> <li class="ss-choice-item"><label class="ss-choice-label"><input name="entry.0.group" value="4" class="ss-q-radio" id="group_0_3" type="radio">
4</label></li>
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:54:20+00:00Added an answer on June 14, 2026 at 3:54 am

    You must find the radio button that is the nearest, following sibling of the <lable> (or text node) you care about.

    jQuery makes this kind of thing easier, See the jQuery documentation, especially the Selectors section and the Traversing section.

    Here’s a complete Greasemonkey script that will select the right button, based on the new HTML in the question (linked Google doc):

    // ==UserScript==
    // @name        YOUR_SCRIPT_NAME
    // @description Auto select rpt radio button
    // @include     http://YOUR_SERVER.COM/YOUR_PATH/*
    // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    // @grant       GM_addStyle
    // ==/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);
    

    You can also See the code in action at jsFiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

need help... the getting input form: <select name=age> <option value=25-30>25-30</option> <option value=31-40>31-40</option> <option value=41-50>41-50</option>
Need help trying to figure out why the button onCLick event isn't working. I
need help to read xml file. i have one xml file which i want
Need help to convert code from asp control to input type to fetch file
Need help parsing... In my code, I have a method that returns url.getHost();. But
Need help with the while command. I want to run a command if there's
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
need help here, been fixing for hours but to no avail. i will like
Need help declaring and implementing a method with blocks but no parameters. Sounds simple
Need help to display the grouped row count in report builder. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.