I currently have a form that will take the dropdown selection in
rebates.php
update.php
action=""
tds
update.php
td
td
td
rebates.php
<form name="myForm" action="">
<!-- Dropdown List -->
<select name="master_dropdown" id="mr_id">
<script>
document.querySelector('#mr_id').addEventListener('change', updateSelection, false);
document.querySelector('#mr_id').addEventListener('change', updateSelection, false);
function updateSelection(event) {
updatetable(this.form);
}
</script>
<option selected value="select">Choose a Master Supplier Title</option>
<?php foreach($master_supp->fetchAll() as $master) { ?>
<option data-name="<?php echo $master['Supplier_Group_Name'];?>">
<?php echo $master ['Supplier_Group_Name'];?>
</option>
<?php } ?>
</select>
</form>
rebates.js
// Reads what the user selects from the drop down list and displays table when a selection is made
function updatetable(myForm) {
var selIndex = myForm.selectedIndex;
console.log();
var selName = $( "#mr_id option:selected" ).text().trim();
console.log(selName);
$.ajax ({
url: "update.php",
method: "POST",
data: {
mr_id : selName
},
beforeSend: function () {
},
success: function(data){
$(".table_div").html(data);
}
});
}
head
update.php
<script>
$('table').each(function() {
if($(this).find('tr').children("td").length < 1) {
$(this).hide();
}
});
</script>
table
class
id
If I understood correctly, you need to refresh your view after the AJAX call. In other words, you have to run your $('table').each(function() {...}
code every time the AJAX call is a success. Try including that after the $(".table_div").html(data)
line in your AJAX success call.