Onchange function in datatables form
Onchange function in datatables form

Hi, I'm working on this form where input2 will change according to input1. Both are select type input. The problem that I'm facing right now is the onchange function only working on the first row. Here is my progress so far. Will appreciate any help for this matter
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @ZulfahmiRadzi ,
The problem is because the ID for the first select is always
input1
- IDs should be unique across the DOM. Because of this, it's only looking at the first instance, the first line.Cheers,
Colin
Hi @colin,
What if I load the table using ajax? How to make different ID for each row?
You would use
columns.render
. Here is an example with buttons. Even though its not select inputs it should give you an idea of what to do. The key is to use themeta.row
parameter to get the row id.Kevin
Problem solved. Thanks for the quick response!