Please follow these steps in the jsfiddle to understand my question
-
Click on open grid link and select option “3”, buttons A,B and C would appear
-
Enter in number 2 in the number of Answers textbox. Then select buttons A and C
-
Now click on the open grid again and select option 6.
-
Now the number of Answers textbox is empty so type in 2 again in the text-box. So only 2 answers should be selected and as A and C is already selected, it should not allow another button to be selected (an alert should appear)
But this does not happen. Instead the user can select another 2 buttons and then the alert message would appear if another button is selected. This means you see 4 buttons being selected which is incorrect, it should still be 2.
So does anyone have an idea why it is doing this? It probably because the click count which somenbody mentioned is being reset everytime the grid is opened and another option is chosen.
Thanks
Code is in jsfiddle, click here
Change this lines in the
btnclickfunction:To this:
Like you have done in the
insertQuestionfunction, getting the number of buttons pressed by using the length of the jQuery object.