Ok this what I am trying to do. I have looked but can't find a good tutorial on how to do this. Here it is.
The user enters the data and submits it. When they go to a dedicated page they can see the line they just wrote along with the other lines that have already been written. Each one should display 'delete | edit'.
Sure, just not a real easy one. I've done this with CSV files. The .js file is a flat file -- thus, you cannot just insert or delete lines in the middle of it. Two ways -- all based on sequential line number (or a line tag which is part of the data): Read it all into memory and write it all out -- including or minus the inserted, updated, or deleted lines. Or, read a line at a time from one file and write a line at a time to a new file -- including or minus the inserted, updated, or deleted lines -- then delete the old file and rename the new file back to the old file name.
That was pretty simple, actually. You could read the file (to an array) a line at a time until you found the line before or after which you wanted to add another line. Then, you'd add it to the array and continue reading. Once you reached the end of the file, you could pump it all back out to a different file, then delete the original and rename the new one to the same name.