You need to research this better, this question has been asked before. You have two issues, when someone visits your site the data is downloaded to your browser, any edits would be client side and not on the server. If you could write to a file and post it to the server, you would have issues of multiple people editing at once and not being in sync. Just imagine someone deleting all the data and posting the empty file back or posting a file with a virus. This concept is a bad idea.
The preferred way is to have a database on a server that you can update records, this requires the web Database and web Services or REST services to serve the data and your page to display it. You would then use an AJAX call to post your updates to the database. Popular methods would be to use PHP, NODE, Python, or others to create the services you need to communicate with your database.
Instead of a popup you could use a sidebar and have the HTML input and buttons coded to insert the data to a new record. Grab the X,Y coords from the mouse click and you have everything for your database.
This answer is very general but your question was not specific and there was no code to troubleshoot. For now this should help you focus your Google searches.