0

input type="checkbox" will not uncheck or checked not unless if confirmed on dialog confirmation box.

Here is the scenario, i have this table contained with records each row of record has an Enabled column which will allow you to checked or unchecked a specific row record means(Disable or enable an account record).

My problem is, when i click the [input type="checkbox"] it will auto check or sometimes when it is checked by default it will auto unchecked then the dialog appears for confirmation for enabling or disabling an account.

I want the checkbox to do nothing when i clicked it. It should only change after i confirm it on dialog box.

Hi guys, sorry this us my code anyway. http://jsfiddle.net/5REXp/1/ I hope you understand it. A Jquery UI dialog should popup when you click the checkbox un column named enabled. Thanks.

1
  • please share your html and the script you tried Commented Sep 24, 2013 at 5:05

2 Answers 2

1

Try

<input type="checkbox" checked="checked" onclick="Enabled(201569,event, this)" />

and

<div id="dialog-confirm">Confirm</div>

then

function Enabled(id, event, el) {
    event.preventDefault();
    $("#dialog-confirm").dialog({
        resizable: false,
        height: 160,
        modal: true,
        buttons: {
            "Disable": function () {
                $(this).dialog('option', 'hide', 'fade');
                $(this).dialog("close");
                $(el).prop('checked', !$(el).is(':checked'))
            },
            Cancel: function () {
                $(this).dialog("destroy");
            }
        }
    });
}

Demo: Fiddle

Sign up to request clarification or add additional context in comments.

1 Comment

This is a some sort of spoon feeding. :D, through stackoverflow we don't care what nationalities or what type of people are here. In here i feel we are united as one. Drama. haha. It is all about knowledge! Magnificent work arun this is the second time you helped me. Thank you.
0

Please try with this code. I think this is what you want:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<form method="post">
<input type="checkbox" name="chk1" class="chkb"/>
<input type="checkbox" name="chk2" class="chkb"/>
<input type="checkbox" name="chk3" class="chkb"/>
</form>

<script type="text/javascript">
$(function(){
    $('.chkb').click(function(){
        var Status=$(this).is(':checked');
        if(Status==true)
        {
            $(this).attr('checked',false);
            var conf=confirm('Mark It?');
            if(conf==true)
                $(this).prop('checked',true);
            else
                $(this).prop('checked',false);
        }
        else if(Status==false)
        {
            //$(this).attr('checked',false);
            var conf=confirm('Unmark It?');
            if(conf==true)
                $(this).prop('checked',false);
            else
                $(this).prop('checked',true);
        }   

    });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.