Skip to content
Advertisement

How to make adjacent col’s input field mandatory based on a selection in another column/same row HTML Table?

There’s quite a few examples around, but I couldn’t find one covering a table. The intent is to have the Comments column’s input field shown as mandatory, if value Rejected or Discuss is selected in an adjacent column.

Here’s a Fiddle

I’ve seen that there should be an onchange added to each row of the table, which would call a function, but there should be an id for each row?

This is how I’m building the table, using GAS:

JavaScript

Appreciate your help!

Advertisement

Answer

Add onChange event for select box like selectValueChanged and then inside the method pass the current object. Using current object , find the selected value and then perform your operations.

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