0

When I click on this checkbox (inside the Modal form)

<input id="selectallcreate" type="checkbox" value="1" name="selectallcreate">

It will always return False using this code

if ($('#selectallcreate').is(':checked') == true){}; 

Also this code will work perfectly on any page that are NOT modal. Other then that the modal form operates perfectly.

2 Answers 2

2

Be sure in your DOM that there's only ONE instance of id selectallcreate. You might be surprised to find that you have two. It's happened to me. I'd say, try locating the checkbox by $('QueryToGetDialogDiv').find("#selectallcreate"), so you can be sure you're grabbing the correct div.

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

3 Comments

I am sure jQuery is not cloning any fields in the dialog. It would defeat the whole purpose.. $('#selectallcreate') is way better than using $('QueryToGetDialogDiv').find("#selectallcreate").
I tried changing it to class="selectallcreate" and its working.
FYI: removed the jQuery part cloning to make the answer more universal as maybe the page creator accidentally put in two of the same IDs.
0

The code you have shared looks fine. It should work fine as long as there are no other script errors.

DEMO here

Please try the demo and let us know if it is different from your code.

4 Comments

its because I was using ID and I add other instance of it. Thanks for the demo
If you take <input id="selectallcreate" type="checkbox" value="1" name="selectallcreate">Checkbox outside the popup to just above the id="dialog-modal" div in your jsFiddle, you will see it fail in the same way as described.
@DMCS Can you edit the fiddle and share the link.. it worked fine when I moved the checkbox outside the popup.
No moved, copied to create a second instance of the same ID. Here's the updated fiddle: jsfiddle.net/dmcs/cGJrr/3

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.