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

  • Home
  • SEARCH
  • 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 9208301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:35:11+00:00 2026-06-18T00:35:11+00:00

This is a very simple use of jQuery that I can’t get working. When

  • 0

This is a very simple use of jQuery that I can’t get working.

When one check box is checked, I’d like the other to become checked.

HTML:

<input onchange="toggleRegion()" id="ESARO" type="checkbox" class="region"
value="ESARO" name="ESARO">ESARO

<br /><br />

<input type="checkbox" class="country" value="Afghanistan" name="country2"
/>Afghanistan

jQuery:

function toggleRegion() {
    if ($('#ESARO').is(':checked')) {
        $('input[value="Afghanistan"]').attr('checked', true);
    }
}

jsfiddle:

http://jsfiddle.net/jsJU8/

What I’ve tried:

I have another function which does a very similar thing for a group of check boxes by class which works perfectly:

function toggleStatus() {
if ($('#TLO1').is(':checked')) {
        $('.country').attr('checked', true);

    } 
}

So I presume that the error lies in the selection of the element by value, rather than by class, as this is the only difference between the functions.

To this end I’ve tried adjusting that selector;’s syntax to match various examples I’ve found (single quote, double quote, no quote etc) but haven’t had any luck.#

Although I note that it may be a possible error that I’m using javascript (onChange) to call a jQuery function. Is that an issue?

All help greatly appreciated – thank you

  • 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-18T00:35:12+00:00Added an answer on June 18, 2026 at 12:35 am

    You code is working but you have to choose no-wrap (body) option in first drop down.

    Live Demo

    function toggleRegion() {
        if ($('#ESARO').is(':checked')) {
            $('input[value="Afghanistan"]').attr('checked', true);
        }
    }
    

    enter image description here

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

Sidebar

Related Questions

This is a very simple thing that I can't seem to get to work.
I have this very simple br2nl function that I use to take a string
For a very simple profiling I use microtime() like this: $now = microtime(); for
I have to use jquery 1.3.2 I have here very simple task to check
There's a very simple jquery plugin: autotextarea. I'd like to teach it one little
In this very simple code example, messages get lost every once in a while.
I have this very simple jQuery function: $(.milestone-in-tree).live({ mouseenter: function() { setTimeout( $.ajax({ type:
I have this very simple example that I am using to learn structs in
This may be something very easy but i can't seem to get this to
I'm a jQuery beginner. I'm trying to code a very simple using $.get(). The

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.