I have a table whose data is being filled dynamically. Each row has a drop-down under status section from which user can select a value and according to the selected value, some input boxes have to be displayed, but these boxes should be displayed in that row in which the drop-down belonged. So, if the drop-down belongs to the first row then the box should appear in the first row only and if the drop-down belongs to the second row then the box should appear in the second row only
Currently, the code that I am using is displaying the input boxes randomly in different rows irrespective of the dropdown position
Can anyone please tell how this can be corrected HTML Code
<table class="table table-bordred table-striped">
<thead>
<th>NAME</th>
<th>STATUS</th>
</thead>
<tbody>
<?php foreach($student as $per_student): ?>
<tr>
<td><?php echo $per_student->name; ?></td>
<td>
<select class="can-dd" onchange="myFunction(this)" name="status">
<option value="">STATUS</option>
<option value="Accepted ">Accepted</option>
<option value="Forwarded ">Forwarded </option>
<option value="Schedule">Schedule </option>
<option value="Custom">Custom</option>
</select>
<div class="schedule">
<input type="text" placeholder="schedule" name="schedule">
<button type="submit" class="btn btn-primary " >SUBMIT</button>
</div>
<div class="custom">
<input type="text" placeholder="custom" name="custom">
<button type="submit" class="btn btn-primary " >SUBMIT</button>
</div>
<div class="submit_value">
<button type="submit" class="btn btn-primary " >SUBMIT</button>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
Script
<script type="text/javascript">
function myFunction(selectObject) {
var value = selectObject.value;
if(value == 'Schedule'){
jQuery('.custom').remove();
jQuery('.submit_value').remove();
$(".schedule").show();
}
else if(value == 'Custom'){
jQuery('.schedule').remove();
jQuery('.submit_value').remove();
$(".custom").show();
}
else{
jQuery('.schedule').remove();
jQuery('.custom').remove();
$(".submit_value").show();
}
}
</script>