ImThatGuy
ImThatGuy

Reputation: 13

Trying to Delete Rows of a Table

So i have a chat room im working on in html and im having an issue, that chatroom is local wifi, and what im trying to do is if i enter a code in an input box, clear the table or current chat.

            <script>
              function myFunction() {
                var letter = document.getElementById("pass").value;
                var text;

                if (letter === "Python") 
                  {
                  document.getElementById("myTable").deleteRow(0);
                  } else {
                  alert("Admin Access Denied");
                  }
                }
            </script>

this is what happens, so say i enter Python in the input box, the code works and it deletes the first line of the table every time i hit enter, and gives an alert if its wrong, but the issue is once i hit enter and it erases the first line, but then i cant put anything in the chat anymore, but when i reload the page it brings back everything i deleted. Also when i delete some lines, it only deletes for me and not everyone else in the room.

I need it to be able to not only erase the entire contents of the table, but i also need it to delete it permanently for everyone in the chat room and the chat room still able to work properly.

LINK: https://project-js-imthatguy.c9users.io/

Upvotes: 1

Views: 42

Answers (1)

Gavin
Gavin

Reputation: 4515

Just because you are deleting the first row in YOUR browser doesn't mean that the HTML will render differently the next time or for everyone else. This deletion needs to happen server side. Consider an AJAX call instead.

Upvotes: 2

Related Questions