So I have multiple anchors that will get their id and text from a directory, these are ip addresses.
I can get the ip address from each when clicked into the title of a modal that the anchors open using this javascript in my php file:
<script>
$(document).on('click', 'a', function () {
document.getElementById("ipaddresstitle").innerHTML = this.id;
var idoftitle = this.id
});
</script>
But I want a file to be displayed in the div 'modal-body'. The file wants to be for example /etc/ip_files/192.168.0.1
if I click 192.168.0.1 button. There will be a file that corresponds to each anchor.
I used this php before:
nl2br( file_get_contents('/etc/ip_files/192.168.0.1') );
it works manually. How can I make the div display the different text file each time I click one?
Is there a way that Javascript can output the file for me? Instead of using php?