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 6093189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:31:54+00:00 2026-05-23T12:31:54+00:00

I am writing a Greasemonkey/Tampermonkey script and I need to turn on radio buttons

  • 0

I am writing a Greasemonkey/Tampermonkey script and I need to turn on radio buttons depending on the name and value of the radio control.

This is how it looks:

<input type="radio" name="11" value="XXX" class="radio">
<input type="radio" name="11" value="zzzz" class="radio">

So I want to set those buttons that have name of 11 and a value of zzzz to be checked.

  • 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-05-23T12:31:54+00:00Added an answer on May 23, 2026 at 12:31 pm

    This is super easy when you use jQuery. Here’s a complete script:

    // ==UserScript==
    // @name     _Radio button check
    // @include  http://YOUR_SITE/YOUR_PATH/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/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.
    */
    $("input[name='11'][value='zzzz']").prop ('checked', true);
    

    The input[name='11'][value='zzzz'] jQuery selector gets all <input>s that have the initial value zzzz, but only if they are in the group of radio buttons with name="11".

    Reference:

    • jQuery
    • jQuery selector documentation
    • jQuery .prop()

    Important:   The above works on most pages but, on AJAX-driven pages, you often need to use AJAX-aware techniques. This is because the Greasemonkey script will run before the checkbox you care about is loaded.

    One way to deal with this is with the waitForKeyElements utility. Like so:

    // ==UserScript==
    // @name     _Radio button check
    // @include  http://YOUR_SITE/YOUR_PATH/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
    // @require  https://gist.github.com/raw/2625891/waitForKeyElements.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.
    */
    waitForKeyElements ("input[name='11'][value='zzzz']", selectRadioButton, true);
    
    function selectRadioButton (jNode) {
        jNode.prop ('checked', true);
    }
    



    Old answer that was “state of the art” 🙂 back when the question was asked:

    // ==UserScript==
    // @name            _Radio button check
    // @include         http://YOUR_SITE/YOUR_PATH/*
    // @require         http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
    // ==/UserScript==
    
    $("input[name='11'][value='zzzz']").attr ("checked", "checked");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a greasemonkey script. The site is using jquery, i need a
I am in the process of writing a Greasemonkey Script for pages in this
I am writing a Greasemonkey script for hundreds similar pages. And want to do
I'm writing a GreaseMonkey script that modifies an attribute of an element with a
Background : I'm currently writing a greasemonkey script that embeds/modifies a specific page's html.
I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent
I'm writing a simple Greasemonkey script to strip out all the images, headings and
I am writing a greasemonkey script that is parsing a page with the following
I'm currently writing a Greasemonkey script for a page, so I can't modify the
I'm writing some javascript (a greasemonkey/userscript) that will insert some input fields into a

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.