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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:10:12+00:00 2026-05-26T13:10:12+00:00

I want to select an Input checkbox element via jQuery and dynamically tick or

  • 0

I want to select an Input checkbox element via jQuery and dynamically tick or untick it.

I am using code like this:

$('input#my_input').attr('checked', true);

Perfectly valid – and that works just fine. However, these Input elements are being dynamically styled by jQuery Uniform CSS – http://uniformjs.com/ – a very nice jQuery library to custom-style elements.

The problem is that Uniform changes the DOM structure slightly by wrapping these elements in custom wrappers (although the input still has the ID I assigned it, etc). I want to use $(...).live with attr but I can’t work out how to pass the attr parameters when using Live.

Can anybody help? Thanks!

EDIT: To make things a bit clearer, I’ve posted some more code below.

My PHP script is outputting a table of users. For each user is five areas of the site they either can or can’t access, in each area they can perform a different task. These are just tickboxes. But I want to have a ‘Preset’ dropdown list that will automatically tick specific task/area access combinations.

Here’s my Preset Switch event:

$('select.preset_switch').change(function() {

    var user_id = $(this).attr('id');
    var preset  = $(this).val();

    switch(preset)
    {
        case 'Area 1':
            setPermissions(user_id, true, true, true, true, true);
            break;

        case 'Area 2':
            setPermissions(user_id, true, true, true, true, true);
            break;

        case 'Area 3':
            setPermissions(user_id, true, true, true, true, true);
            break;

        case 'Area 4':
            setPermissions(user_id, true, true, true, true, true);
            break;

        case 'Area 5':
            setPermissions(user_id, true, true, true, true, true);
            break;

        case 'Area 6':
            setPermissions(user_id, true, true, true, true, true);
            break;

        case 'Inactive User':
            setPermissions(user_id, false, false, false, false, false);
            break;
    }
});

The setPermissions() function:

// Sets the Input tickboxes for permissions editor
function setPermissions(user_id, task1, task2, task3, task4, task5)
{
    $('input#permission_task1_'+user_id ).live(function() {
        $(this).prop('checked', task1);
    });
    $('input#permission_task2_'+user_id ).live(function() {
        $(this).attr('checked', task2);
    });
    $('input#permission_task3_'+user_id ).live(function() {
        $(this).attr('checked', task3);
    });
    $('input#permission_task4_'+user_id     ).live(function() {
        $(this).attr('checked', task4);
    });
    $('input#permission_task5_'+user_id ).live(function() {
        $(this).attr('checked', task5);
    });
}

I know for now, everything is set to ‘true’ – this is just to make testing clearer. I will set up proper access configurations later on.

Finally, my HTML looks like this (one row of many dynamic ones):

<tr>
    <td>John Smith</td>
    <td>
        <input type="checkbox" name="area1[]" id="permission_task1_1044" class="permission_checkbox" value="1044"  />
    </td>
    <td>
        <input type="checkbox" name="area2[]" id="permission_task2_1044" class="permission_checkbox" value="1044"  />
    </td>
    <td>
        <input type="checkbox" name="area3[]" id="permission_task3_1044" class="permission_checkbox" value="1044"  />
    </td>
    <td>
        <input type="checkbox" name="area4[]" id="permission_task4_1044" class="permission_checkbox" value="1044"  />
    </td>
    <td>
        <input type="checkbox" name="area5[]" id="permission_task5_1044" class="permission_checkbox" value="1044"  />
    </td>
    <td>
        <select class="preset_switch" id="1044">
            <option>Select a preset</option>
            <option>Area 1</option>
            <option>Area 2</option>
            <option>Area 3</option>
            <option>Area 4</option>
            <option>Area 5</option>
            <option>Area 6</option>
            <option>Inactive User</option>
        </select>
    </td>
</tr>

EDIT 2: Problem solved. Had to use $.uniform.update() on my element so that uniform would visually update it – it was working correctly the first way I did it, just not refreshing the display. Still doesn’t explain the error on live() but hey, it works!

  • 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-26T13:10:12+00:00Added an answer on May 26, 2026 at 1:10 pm
    $('#the_trigger').live('the_event_you_are_binding_to', function(){
        $('#my_input').attr('checked', true);
        // return false; // depending on your needs
    });
    

    http://api.jquery.com/live/

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

Sidebar

Related Questions

html code: <div> <input type=checkbox onclick=selectAll(this); />select all<br/> <input type=checkbox /><br/> <input type=checkbox /><br/>
I'm using jQuery's dynaTree in my application and I want to select the all
Here's some example code: <input type=checkbox id=send-notice name=send-notice value=1 /> This is a notice
I want to use a JQuery check all function in a form like this:
Q1: I create a jQuery clickable I want when click on input:checkbox in rows
I want to select the topmost element in a document that has a given
I want to select all the input-children of the div-children of my mainDiv. I
i want to select a checkbox when a button is clicked. <form action= method=post
This is the code that i use to find whether any checkbox is checked
I am implementing an HTML form with some checkbox input elements, and I want

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.