I have 2 Radio Buttons that are used to select between 2 locations so that a different PHP page can be loaded from an external file when selected. But the file does also need to have an automatic refresh so that it can show the most up to date information every 3 minutes.
These are my radio buttons:
<div class="locationdrop">
<div class="dropbtn">Location</div>
<div class="locationlist">
<input type="radio" id="location1" name="location" value="Location 1" class="locationinput" checked="checked">
<label for="location1" class="locationlabel">Location 1</label>
<input type="radio" id="location2" name="location" value="Location 2" class="locationinput">
<label for="location2" class="locationlabel">Location 2</label>
</div>
</div>
</div>
This is my Script (using an auto updating AJAX):
<script>
$(document).ready(function() {
function getData() {
if(document.getElementById('location1').checked) {
$.ajax({
type: 'POST',
url: 'location1data.php',
success: function(data){
$('#locationoutput').html(data);
}
});
}else if(document.getElementById('location2').checked) {
$.ajax({
type: 'POST',
url: 'location2data.php',
success: function(data){
$('#locationoutput').html(data);
}
});
getData();
setInterval(function () {
getData();
}, 120000); // it will refresh your data every 3 mins
};
};
});
</script>
This is my original (working) code to load the php into the div:
<script>
$(document).ready(function(){
function getData(){
$.ajax({
type: 'POST',
url: 'locationData.php',
success: function(data){
$('#locationoutput').html(data);
}
});
}
getData();
setInterval(function () {
getData();
}, 120000); // it will refresh your data every 1 sec
});
</script>
I just need it to choose between 2 of these using the radio buttons.
Assistance would be greatly appreciated :)