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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:53:02+00:00 2026-06-03T16:53:02+00:00

I have some set of links and select boxes. My html code is below:

  • 0

I have some set of links and select boxes. My html code is below:

<div>
    <div>
        <a href='#' onclick='set_checked(false,"checkbox1")'>clear</a>
        <a href='#' onclick='set_checked(true,"checkbox1")'>select</a>
    </div>
    <div>
        <input type='checkbox' name='checkbox1'/>
    </div>
</div>

<div>
    <div>
        <a href='#' onclick='set_checked(false,"checkbox2")'>clear</a>
        <a href='#' onclick='set_checked(true,"checkbox2")'>select</a>
    </div>
    <div>
        <input type='checkbox' name='checkbox2'/>
    </div>
</div>

Now my requirement is when I click on select link I have to check the checkbox based on it’s arguments, and reversal for clear. Here I’m passing two parameters. One is to pass Boolean value (i.e. if true check else uncheck) and another one is to pass name argument of a checkbox field.
And I’m using the following function to check or uncheck a checkbox:

function set_checked(checked,inputFeildName){
   $('input[name=inputFeildName]').attr('checked',checked);
} 

but the above code is not working. And this is my fiddle http://jsfiddle.net/vu6fs/5/.

I have one more requirement, before selecting any checkbox all clear links have to be disabled, after selection of checkbox respective clear link have to be enable. I’m applying opacity and also ‘disabled’ property in JavaScript but it’s not working,can anyone suggest me where my fault is..

Can anyone please help me?

  • 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-03T16:53:04+00:00Added an answer on June 3, 2026 at 4:53 pm

    jQuery 1.6+

    function set_checked(checked,inputFeildName){
    
       $('input[name="'+ inputFeildName +'"]').prop('checked',true);
    
    } 
    

    jQuery 1.5 and below

    function set_checked(checked,inputFeildName){
    
       $('input[name="'+ inputFeildName +'"]').attr('checked','checked');
    
    } 
    

    Here is an example for your extension of question (more you want, About disable/enable a tag on checkbox change)

    CSS

    .disButton {
        background: transparent;
        border: none;
    }
    .disButton a {
        text-decoration: none;
        color: #ddd;
    }
    

    jQuery

    $('input:checkbox').on('change', function() {
        enable_clear(this, this.checked);
    }).change();
    
    function enable_clear(el, checked) {
        var target = $(el).parent('div').prev('div').find('a:contains(clear)');
        if (checked) {
            target.unwrap();
        } else {
            target.wrap($('<button/>', {
                disabled: true,
                'class': 'disButton',
                width: target.width() + 'px'
            }));
        }
    }
    $('a').on('click', function(e) {
        e.preventDefault();
        var target = $(this).parent().next('div').find('input:checkbox');
        if (!target.is(':checked') && $(this).text() == 'select') target.click();
        if ($(this).text() == 'clear') target.click();
    });
    

    DEMO

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

Sidebar

Related Questions

Do you have some predefined set of targets which all build.xml files you create
I'm working on a Rails application where I have some a set of two
In my init I have set some variables and one animate that uses those
I have one AlertDialog which is working fine.I have set some background images to
I have some jquery/php interaction set up on a page. It submits some data
I have to set some routing rules in my php application, and they should
I have some logic that depends upon two properties being set, as it executes
I want to set my GtkComboBox to have some default value/name, on it as
We have some examples of pictures. And we have on input set of pictures.
I have some PDF files in a public rails folder. I want to set

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.