text inputs don't show or hide when it should do - javascript

I have a jsfiddle here: http://jsfiddle.net/ybZvv/22/
The situation I have is that if you click on "Select All Answers" button, it will turn on all the letter buttons (al trun green). Now if you click on the "Add Question" button it appends the buttons from the top into a table row. You will see a bunch of text inputs appear below the table, this shows the values of all of the buttons which are turned on in the appended row.
This is fine. But the problem is below:
The problem though is that if you click on the "Remove All Answers" button IN THE APPENDED ROW, then all of the buttons are turned off which is fine but it does not remove/hide the text inputs for all of those values which buttons are turned off.
If you then click on the "Select All Answers" button IN THE APPENDED ROW, then it turns all ofthe buttons in the row but no text input appears showing all of the values which buttons are turned on.
So my question is that if the user clicks on the "Select All Answers" button in an appended table row, how can we get it to display all of the text inputs of the buttons which are turned on in that row?
Also if the user clicks on the "Remove All Answers" button in the appended row, I want it to remove all of the text inputs of those buttons turned off within that row. How can this be achieved?

The solution is to "trigger" a click on the buttons instead of simply taking off one class and adding another.
So instead of
$('.answerBtns:visible', context).removeClass('answerBtnsOff').addClass('answerBtnsOn');
you should use:
$('.answerBtnsOff:visible', context).trigger('click');
to simulate a click on the button to do proper handling.
Here's the edited fiddle

Related

Uncheck radio button datatable with pagination

I have a datatable with radio buttons for every row, my problem is that when i check the radio button in first page for example and go to another page and check another radio button i sow that the first one (in page one) still checked.
Expected : When i select a row, then i change the page in the table, and if i re-select a row, the value of the previous page must be deselected.
I'm using this https://datatables.net/examples/data_sources/js_array
thinks

Jquery function to hide one div on button click not all of them

So in this code i generate divs on button click and i need to wrote a jquery function to hide the div but if i make 2 or more divs on the button click every one of them dissapears and i only need to hide just the one that i press the button on
$("#payBtn").click(function(){
$("#div5").hide(1000)
Here is the code snippet so you can try it and see what im trying to achieve : https://codesandbox.io/s/twilight-star-26ybq7?file=/index.html
the ID input has to have at least 3 capital letters and 10 characters like:123SSSgggg.

Select and deselect row after another selection - ReactJS Hooks

Have a list of licenses plates that start with a disabled button and no line selected.
Here is what should to do:
When select a row, button "Go foward" enable;
When select a row already selected, deselect it and disabled button again.
When list have a row selected and user click in another row, deselect old row and select the new one.
The snippet code i did:
https://codesandbox.io/s/busy-galileo-mw3p3?fontsize=14&hidenavigation=1&theme=dark
Facing this problems:
Need 2 clicks to set css style 'custom-col-row-active' to row selected. Button is enable already first click.
When a line is already selected, when you click on the other lines, they are selected as well. With 1 click on a selected line, all are deselected.
I know need use data table to deselect line already select, but i don't know how to get the full data table, since i only get the data when i click in a specif row.
Any tips here?
#Rafael, I don't know much about tabler-react, but this is just my suggestion for you. Your handleSetActivedRow seems to have problem. I don't understand why you have written onClick={(e) => handleSetActivedRow(e)}. You are calling a function inline when onClick itself and again you are taking it to an other function handleSetActivedRow. This is bad coding; instead you can do like this onClick={handleSetActiveRow}. secondly, you need to check again your handleSetActiveRow function. I don't understand why you want to return? when it is not necessary. What you need to check on is that you want to set the className to -active when you click on an element.

Can't click or select an item from javascript dropdown menu using VBA

As the title suggests, I've found the ClassName of the button I want to click (I think, because the innertext on that ClassName array # gives me the correct text shown on button). Problem is, I'm clicking it but it does nothing.
This is my best attempt, among dozens, but it's not doing anything.
For Each i In IE.document.getElementById("typeSelector")
If i.innerText = "Revenue" Then
i.Click
i.FireEvent ("onchange")
'This click and fireEvent are activated but do nothing.
End If
Next i
'These next ones are Hail Mary's stacked on top of each other to see if I get a reaction out of that damn box. Nada.
Debug.Print IE.document.getElementsByClassName("chzn-single chzn-default")(0).innerText 'Prints "Select an option". I thought clicking this would at least open the drop down menu but still, nothing.
Debug.Print IE.document.getElementById("typeSelector_chzn_o_14").innerText 'Prints "Revenue". This is the option within the dropdown menu, shown after clicking the menu when manually done.
IE.document.getElementsByClassName("chzn-single chzn-default")(0).Click
IE.document.getElementById("typeSelector_chzn_o_14").Click
To summarize, I've tried activating the option based on index, clicking the box, clicking the box then clicking the "Revenue" option. The website remains completely unmoved. Should be noted that a succesful click would not update the website, simply highlight the "Revenue" option in the menu, and open up a Date input box.

It is not copying buttons when appending table row

I am having trouble copying buttons into an appended row:
I have a jsfiddle: http://jsfiddle.net/Bjqr6/37/
In the jsfiddle, if you click on the "Open Grid" link and select either "True or False" button or "Yes or No" button, it will display those buttons at the bottom.
Now turn one of those buttons on by clicking on it (button will turn green)
Now the problem is that if you click on the "Add Question" button to append you buttons into a table row, you will see it does not copy the buttons into the table row.
Does anyone know why it does not copy the buttons and append them in the row?
I basically added
var $ans = context.find('.answerBtnsOn');
var $answer = $("<div class='answer'>Answer:<br/></div>").append($ans.val());
See http://jsfiddle.net/Bjqr6/40/. Is this what you want?

Categories