I have a form with a dropdown menu followed by a text input field. The input box is disabled by default. Selecting a specified option ("OTHER") from the menu should enable the text field.
Note: The user can add multiple row(s) if he clicks on the icon(+). The other row(s) will not be affected when a certain row selects "OTHER". Only the row(s) having the option "OTHER" will be enable.
<tr id="dataRow">
<td>+</td>
<td>-</td>
<td>
<select onChange="checkOption(this);">
<option value="A">Option A</option>
<option value="B">Option B</option>
<option value="C">Option C</option>
<option value="OTHER">Other</option>
</select>
</td>
<td><input id="inputTextBox"></td>
</tr>
JAVASCRIPT:
function checkOption(obj) {
var input = document.getElementById("inputTextBox");
input.disabled = obj.value != "OTHER";
}
Sample:
First Row: Selects OTHER (inputTextBox is enabled)
User add another Row: Selects Option A (inputTextBox is disabled)
User add another Row: Selects OTHER (inputTextBox is enabled)
The HTML is something like this when multiple row(s) is generated. Sharing the same ids, options..
<tr id="dataRow">
<td>+</td>
<td>-</td>
<td>
<select onChange="checkOption(this);">
<option value="A">Option A</option>
<option value="B">Option B</option>
<option value="C">Option C</option>
<option value="OTHER">Other</option>
</select>
</td>
<td><input id="inputTextBox"></td>
</tr>
<tr id="dataRow">
<td>+</td>
<td>-</td>
<td>
<select onChange="checkOption(this);">
<option value="A">Option A</option>
<option value="B">Option B</option>
<option value="C">Option C</option>
<option value="OTHER">Other</option>
</select>
</td>
<td><input id="inputTextBox"></td>
</tr>
<tr id="dataRow">
<td>+</td>
<td>-</td>
<td>
<select onChange="checkOption(this);">
<option value="A">Option A</option>
<option value="B">Option B</option>
<option value="C">Option C</option>
<option value="OTHER">Other</option>
</select>
</td>
<td><input id="inputTextBox"></td>
</tr>
locateFromelement. also can show an example of<select>tag values.dynamicallyin the title? The word has nothing to do with the questionotheryou want to disable the input element right? Is that it?