I've create a simple log viewer, that, when you click on the log you want to see, it display the textarea and display none the 3 others and if you choose another one, it display that one and display none the 3 others again.
It work with what I did, but it's way not optimise and I would like to know a way to optimise that kind of stuff, here's my code:
var txtarea1 = document.getElementById("txtarea1");
            var txtarea2 = document.getElementById("txtarea2");
            var txtarea3 = document.getElementById("txtarea3");
            var txtarea4 = document.getElementById("txtarea4");
            var btn1 = document.getElementById("btn1");
            var btn2 = document.getElementById("btn2");
            var btn3 = document.getElementById("btn3");
            var btn4 = document.getElementById("btn4");
            btn1.addEventListener('click', ftxtarea1);
            btn2.addEventListener('click', ftxtarea2);
            btn3.addEventListener('click', ftxtarea3);
            btn4.addEventListener('click', ftxtarea4);
            function ftxtarea1() {
                if (txtarea1.style.display == "none") {
                    txtarea1.style.display = "block";
                    txtarea2.style.display = "none";
                    txtarea3.style.display = "none";
                    txtarea4.style.display = "none";
                }
            }
            function ftxtarea2() {
                if (txtarea2.style.display == "none") {
                    txtarea1.style.display = "none";
                    txtarea2.style.display = "block";
                    txtarea3.style.display = "none";
                    txtarea4.style.display = "none";
                }
            }
            function ftxtarea3() {
                if (txtarea3.style.display == "none") {
                    txtarea1.style.display = "none";
                    txtarea2.style.display = "none";
                    txtarea3.style.display = "block";
                    txtarea4.style.display = "none";
                }
            }
            function ftxtarea4() {
                if (txtarea4.style.display == "none") {
                    txtarea1.style.display = "none";
                    txtarea2.style.display = "none";
                    txtarea3.style.display = "none";
                    txtarea4.style.display = "block";
                }
            }
Here's the php that eco the HTML code:
echo <div id="log_textarea">';
                echo '<textarea id="txtarea1" rows="15" readonly style="display:none;">' . $loginAttempt . '</textarea>';
                echo '<textarea id="txtarea2" rows="15" readonly style="display:none;">' . $loginHistory . '</textarea>';
                echo '<textarea id="txtarea3" rows="15" readonly style="display:none;">' . $view . '</textarea>';
                echo '<textarea id="txtarea4" rows="15" readonly">' . $editingHistory . '</textarea>';
                echo '</div>';
 
    