Skip to content
Advertisement

Hiding a button dependant on cell value in table

I currently have a table that data is being reported into with a few buttons at the end to perform actions (Consign, Unconsign, Edit, Delete). I’m trying to hide the Consign and Unconsign buttons for each row in the table depending on the Yes/No value a column.

So far, I’ve managed to get the button Consign to hide if the consigned cell is Yes. The problem is that for cells returning No, the Consign button is still hidden and the Unconsign button still shows. What would be the best way to fix this?

Here is the code and example so far.

JavaScript

Image of table buttons

Edit: The suggestion here doesn’t work for me as it’s an issue with a php table with many more variables and not a singular div. I have already managed to hide part of what I’m trying to achieve so I know my code works to an extent and the suggested solutions woulnd’t acheive this for me as it would hide everything.

Advertisement

Answer

I found something in your logic (if statement)

JavaScript

Suggest:

modify if statement

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement