Currently I display all options. I would like to display only the results when the option is selected.
Once the selected option is selected, the input need to be required.
it should be done with table tr td tags. See example below
Thank you for your explanation, advice and support.
$(document).ready(function(){
$('#problem').on('change', function(){
$('.display, .display_1').show();
if (this.value.trim()) {
if (this.value !== 'test') {
$('.display').hide();
}
else if (this.value !== 'test1') {
$('.display_1').hide();
}
}
});
});
$(document).ready(function(){
$('#router').prop('required',true);
$('#switch').prop('required',true);
$('#box').prop('required',true);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
<form id="e">
<table id="tableId">
<tr>
<td>Problem:</td>
<td><select required id="problem" name="problem">
<option value=""></option>
<option value="test">test</option>
<option value="test1">test1 </option>
</select>
</td>
</tr>
<tr class="display" style="display:none;">
<td>Router</td>
<td><input id="router" name="router" type="text" maxlength="50" size="50"></td>
</tr>
<tr class="display_1" style="display:none;">
<td>Switch</td>
<td><input id="switch" name="switch" type="text" maxlength="50" size="50"></td>
</tr>
<tr class="display_1" style="display:none;">
<td>Box</td>
<td><input id="box" name="box" type="text" maxlength="50" size="50"></td>
</tr>
<tr>
<td><input type="submit" class="submit" value="submit"></td>
</tr>
</table>
</form>