javascript checkbox - uncheck only on bootstrap modal OK

user1261774

I have a checkbox that I need to add some javascript to.

I am having issues getting this to work because I have a bootstrap modal that has Cancel and Confirm buttons.

I am unsure how to pass the un-check reference to the modal code and uncheck the checkbox on on the Confirm button. I have made many attempts but failed on all attempts.

How do I do un-ceck the checkbox only when the user selects the Confirm button on the bootstrap modal. When the user selects the modal Cancel button, the checkbox should stay checked.

Here is the checkbox code that I currently have:

<input type="checkbox" name="selected_items" value="{{ id }}" {% if selected %}checked="checked"{% endif %} data-confirm="Are you sure you want to uncheck this?" />

Here is the bootstrap modal code that I have:

    $(document).ready(function() {

        $('input[data-confirm]').click(function(ev) {

            var href = $(this).attr('href');

            if (!$('#dataConfirmModal').length) {

                $('body').append('<div id="dataConfirmModal" class="modal modal-confirm-max-width" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true"><icon class="icon-remove"></icon></button><h4 class="modal-title" id="dataConfirmLabel">{% trans "Confirm" %} - {{ resume_detail_temp_value }}</h4></div><div class="modal-body"></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>&nbsp;&nbsp;<a class="btn-u btn-u-blue" id="dataConfirmOK">{% trans "Confirm" %}</a></div></div>');

            }

            $('#dataConfirmModal').find('.modal-body').html($(this).attr('data-confirm'));

            $('#dataConfirmModal').modal({show:true});

            $('#dataConfirmOK').click(function() {

                // handle checkbox function here.

            });

            return false;

        });

    });
sbonkosky

Is this what you're looking for?

$('#dataConfirmOK').click(function() {
    $('input[name=selected_items]').prop('checked', false);
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

uncheck Bootstrap checkbox buttons - Pure JavaScript

From Dev

checkbox event only on check, not on uncheck

From Dev

Uncheck a checkbox if another checked with javascript

From Dev

How to uncheck a checkbox in pure JavaScript?

From Dev

Check only the checkbox if Yes button was clicked on bootstrap modal

From Dev

jstree to check uncheck only if clicked on checkbox not on label

From Java

Check/Uncheck checkbox with JavaScript (jQuery or vanilla)?

From Dev

uncheck checkbox using data attributes in javascript

From Dev

Javascript - Check/Uncheck Checkbox Based on Array Values

From Dev

How to Uncheck checkbox when i choose YES option from modal?

From Dev

display a bootstrap modal if checkbox is checked

From Dev

Bootstrap CheckBox Into TabPanel Tab Doesn't Check/Uncheck

From Dev

Unable to check/uncheck checkbox when inside Bootstrap dropdown

From Dev

Javascript - check/uncheck checkbox after summing different inputs

From Dev

Javascript - check/uncheck checkbox after summing different inputs

From Dev

Javascript checkbox Uncheck all works, but Check all doesn't

From Dev

check/uncheck checkbox to show/hide an input file element using javascript

From Dev

Javascript Variable to Bootstrap Modal

From Dev

How to get value checkbox on modal bootstrap

From Dev

jQuery checkbox validation not working inside bootstrap modal

From Dev

Add a confirm bootstrap modal/dialog to checkbox

From Dev

Only one bootstrap modal works

From Dev

Bootstrap Modal shown only once

From Dev

uncheck a checkbox in angularjs

From Dev

changing checkbox style on uncheck

From Dev

ReactJs Checkbox - cannot uncheck

From Dev

How to programmatically uncheck checkbox?

From Dev

wxPython Check and Uncheck checkbox

From Dev

Uncheck a Checkbox using Jquery

Related Related

  1. 1

    uncheck Bootstrap checkbox buttons - Pure JavaScript

  2. 2

    checkbox event only on check, not on uncheck

  3. 3

    Uncheck a checkbox if another checked with javascript

  4. 4

    How to uncheck a checkbox in pure JavaScript?

  5. 5

    Check only the checkbox if Yes button was clicked on bootstrap modal

  6. 6

    jstree to check uncheck only if clicked on checkbox not on label

  7. 7

    Check/Uncheck checkbox with JavaScript (jQuery or vanilla)?

  8. 8

    uncheck checkbox using data attributes in javascript

  9. 9

    Javascript - Check/Uncheck Checkbox Based on Array Values

  10. 10

    How to Uncheck checkbox when i choose YES option from modal?

  11. 11

    display a bootstrap modal if checkbox is checked

  12. 12

    Bootstrap CheckBox Into TabPanel Tab Doesn't Check/Uncheck

  13. 13

    Unable to check/uncheck checkbox when inside Bootstrap dropdown

  14. 14

    Javascript - check/uncheck checkbox after summing different inputs

  15. 15

    Javascript - check/uncheck checkbox after summing different inputs

  16. 16

    Javascript checkbox Uncheck all works, but Check all doesn't

  17. 17

    check/uncheck checkbox to show/hide an input file element using javascript

  18. 18

    Javascript Variable to Bootstrap Modal

  19. 19

    How to get value checkbox on modal bootstrap

  20. 20

    jQuery checkbox validation not working inside bootstrap modal

  21. 21

    Add a confirm bootstrap modal/dialog to checkbox

  22. 22

    Only one bootstrap modal works

  23. 23

    Bootstrap Modal shown only once

  24. 24

    uncheck a checkbox in angularjs

  25. 25

    changing checkbox style on uncheck

  26. 26

    ReactJs Checkbox - cannot uncheck

  27. 27

    How to programmatically uncheck checkbox?

  28. 28

    wxPython Check and Uncheck checkbox

  29. 29

    Uncheck a Checkbox using Jquery

HotTag

Archive