I'm making a webpage that shows data from two different locations in the form of a table. I have a select dropdown menu to select the location. On selecting the location, I'd like to change the table contents to match that location.
I already have the HTML string needed for the table contents (in a php variable that I get from a python script when the page loads), I just need to be able to replace the current table data with the new string.
I've looked online but all the answers I find are about replacing data in individual rows.
This is what I have:
HTML:
<select name="site_switch_location" id="site_switch_location"
onchange="changeTableData()">
<?php echo $resultData["site_switch_fill"] ?>
</select>
<table id="all_data" align="center">
<?php echo $resultData["table_fill"][$_SESSION["location"]] ?>
</table>
Javascript:
<script type="text/javascript">
function changeTableData() {
var new_location = document.getElementById("site_switch_location").value;
var table_data = <?php echo $resultData["table_fill"][new_location] ?>;
document.getElementById("all_data").innerHTML = table_data;
}
</script>