I installed a demo for this problem, which you can access by clicking on DEMO
- Step 1: When you open the demo version, click the "Open Grid" link and select the "7" button. This will display a text box and 7 letter buttons at the bottom.
- Step 2: Select 2 letter buttons under your choice. (when green is selected, the button is selected)
- Step 3: Now on the left side you will see a green plus button, click on it, and it opens a modal window.
- Step 4: There is a search bar in the modal window, enter “AAA” and submit the search, you will see a row of lines.
- Step 5: In the first row, you see under the column “Number of answers” ​​that it contains the number 1, click the “Add” button in this row, the modal window will close, but there is a problem, since the text box “Number of answers” ​​does not display “1 " It displays "2", the reason for this is explained below:
Problem:
In the text box “Number of answers” ​​it should display the number 1, as in the column “Number of answers” ​​in the added row, it indicated the number “1”, but it does not display 1 in the text box, it displays the number 2 and the reason why it displays this number because I have this line of code below.
Now this is due to this code:
$('.answertxt', context).val(context.find('.answerBtnsOn').length > 0 ? context.find('.answerBtnsOn').length : '');,
in $('.gridBtns').on('click', function() , but I need this code.
The reason I need this code is because it allows you to say that there are 7 letter buttons "AG" and you include all the letters, the text box will display the number "7", but if I change my mind and I only want display the 5 letter buttons "AE", then the text field will change from "7" to "5", since now only 5 buttons are enabled. This is why I need this code.
So my question is, if the user clicked the “Add” button, how can I get the number from the “Number of responses” column in the added row displayed in the text box?
Below is the code that assumes that it displays the number in the text box when the "Add" button is clicked ...
function addwindow(numberAnswer, gridValues, btn) { $('#mainNumberAnswerTxt').val(numberAnswer); $('#btn'+gridValues).trigger('click'); }
but $('#mainNumberAnswerTxt').val(numberAnswer); written above because of "$('#btn'+gridValues).trigger('click');" , since this line of code starts this function $('.gridBtns').on('click', function() , and this function contains code, below which it is checked how many buttons are currently enabled after the user clicked the grid button:
$('.answertxt', context).val(context.find('.answerBtnsOn').length > 0 ? context.find('.answerBtnsOn').length : '');,