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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:29:36+00:00 2026-05-27T22:29:36+00:00

I made a method for my UI class that clears inputs in a containing

  • 0

I made a method for my UI class that clears inputs in a containing div.

The problem is, once it is called, The checkboxes never get set through AJAX calls until you refresh the page. The example below is for my group/user management. If you click on a group to edit, a jQuery UI dialog pops up with the attributes and permissions of that group. If you cancel, and try to add a new one, the inputs are cleared. If you then goto edit a group after that, the inputs are not updated.

Edit: It seems the checkboxes stop working if the cancel button is clicked regardless if my clearInputs method is called or not.

Here is the method of the UI class:

clearInputs: function(container) {

    $(container + " :input").val("");
    $(container).find('input[type=checkbox]:checked').prop('checked', false);
}

And an example of the calling code (copied from my project, but I cut some of the fat out…

/* The user clicks the edit group button... */
$(document).delegate('.group_edit', 'click', function() {
    var groupId = $(this).attr('id').replace("group_edit_", "");

    // This call to the clearInputs method is commented out,
    // and behaves as I described above.    
// ui.clearInputs("#dialogGroup");

$.ajax({
    type: "POST",
        url: "ajax.users.php",
    data: {
        action: "get_privs",
        group: groupId
    },
    success: function (result) {
        if (result.success == true) {
        // Set the name value
        $("#name").val(result.GroupName);

        // Update each of the checkboxes
        $.each(result.privs, function(priv, grant) {
            grant = Boolean(parseInt(grant));
        $('#dialogGroup input[value=' + priv + ']').prop('checked', grant);
        });

        /* Create the dialog */
        $("#dialogGroup").dialog({
        buttons: {
        "OK" : function () {
            $(this).dialog("close");

            var form_data = new Array();

                        $.each($("input[@name='cbox[]']:checked"), function() {
                form_data.push($(this).val());
            });

            $.ajax({
                            /* Saves the form data */

            });
        },
        "Cancel": function() {
            ui.clearInputs("#dialogGroup");
        $(this).dialog("close");
        }
}
});

And finally to add a group:

$(document).delegate('#group_add', 'click', function() {
var dialog = "#dialogGroup";

// ui.clearInputs(dialog);

$(dialog).dialog({
    modal: true,
    title: "Create Group",
    buttons: {
        "OK": function() {
        $(this).dialog("close");
        $("#dialogNotify").html("Saving...");
        $("#dialogNotify").dialog('open');
        var form_data = new Array();

                $.each($("input[@name='cbox[]']:checked"), function() {
            form_data.push($(this).val());
        });


        $.ajax({
                    /* Save the form data */
        });

},
Cancel: function() {
    $(this).dialog("close");
}
}
});


});

I hope I included everything… If not I will update.

  • 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-27T22:29:36+00:00Added an answer on May 27, 2026 at 10:29 pm

    try this:

    $( document ).ready(function()
    {
        var search_on = $('#formX');
    
        $( search_on )
    
        //CHANGE "input" for "input,select" to search all fields
        .find('input')
    
        .each(function( e )
        {
            if( $(this).attr('type') == 'radio' || $(this).attr('type') == 'checkbox' )
            {
                $(this).attr('checked',false);
                //USE RESET() IF IS A FORM FIELD
                $(this).reset();
            }
    
            //IF IS A DROPDOWN
            /*
            else if( $(this).attr('type') == undefined )
            {
                $(this).find('option').attr('selected',false);
            }
            */
    
            else
            {
                $(this).val('');
                //USE RESET() IF IS A FORM FIELD
                //$(this).reset();
            }
    
        });
    });
    

    Or use this function( if is a form ):

    jQuery.fn.reset = function () {
      $(this).each (function() { this.reset(); });
    }
    

    And Call

    $('#formX').reset();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI I made a method in my class that is: public void addInfo(String username,
I am trying to make a method in a new class that I made...
I've made a very simple REST controller method with Spring 3.0.0.RC1 that uses hibernate
I've made a program for my OOP class that does the following: Defines a
In my webapplication (C#, .Net 3.5), made up of a core class library (containing
I made a class that derives from Component: public class MyComponent: System.ComponentModel.Component { }
I made a method like this class PersonCollection { [Contracts.CanReturnNull] //dont know if something
I have a JavaScript class that I have made and put it into its
I made this method + (CGFloat) round: (CGFloat)f { int a = f; CGFloat
I'm using the PassthruAPP method to hook into HTTP/HTTPS requests made by IE. It's

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.