Intercepted Posted July 14, 2011 Share Posted July 14, 2011 Is it possible to give the user the ability to add rows to a table through a button or input box and have it save the added rows permanently?Right now I have the ability to add rows working but once I refresh the page the rows are gone.This is how I'm currently doing to add a new row: $('#myTable > tbody:last').append('<tr><td></td></tr>'); Link to comment Share on other sites More sharing options...
thescientist Posted July 14, 2011 Share Posted July 14, 2011 Javascript only lives as long as the page lives. In order to preserve state like that, you are most likely going to want to employ a database (or a file could work) to maintain/preserve the content permanently. Link to comment Share on other sites More sharing options...
Intercepted Posted July 14, 2011 Author Share Posted July 14, 2011 Can I use a file like an XML document without having to run a php server? Is there a way to do this all client side?I just want it to be possible for someone with no knowledge of HTML to be able to add new entries Link to comment Share on other sites More sharing options...
thescientist Posted July 14, 2011 Share Posted July 14, 2011 Can I use a file like an XML document without having to run a php server? Is there a way to do this all client side?I just want it to be possible for someone with no knowledge of HTML to be able to add new entriesthere's really no way to do it on the client side unless you were able to make use of HTML5's local storage, but as to be expected, its support is limited. You can use any file that you are comfortable using. It could be argued that one can make a basic user/admin interface so that anyone wishing to update the entries can use that to interface with database instead.edit: for clarity though, it would be best if you could supply more details on the data you are trying to store, given it's complexity is what would best determine the path (and file type) to choose.edit edit: localStorage would be user dependent, and not persist for anyone but that one specific user. Link to comment Share on other sites More sharing options...
Intercepted Posted July 14, 2011 Author Share Posted July 14, 2011 What I'm trying to do is have a phone list on a HTML web page to circulate around the building for people. Every week or so it needs to be updated and I'm looking for an easy way to do that. The person updating the phone list won't have a lot of knowledge in HTML so I want to make it as simple as possible. PHP and server side methods are not an option since I'm working in a controlled environment. The data isn't complicated at all, it's just a list of names and numbers. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 14, 2011 Share Posted July 14, 2011 You can't do it without a server to process and save the data, end of story. Any other alternative means the changes only appear on a single computer, and would require a specific browser. If you want a centralized server-based application that anyone can update and view, then you obviously need a server that is capable of processing the data. Maybe you should set up a Google Docs spreadsheet and give everyone access to that, which would require Google accounts for each person. Link to comment Share on other sites More sharing options...
thescientist Posted July 14, 2011 Share Posted July 14, 2011 what do you define as a controlled environment? As in no access to PHP/SQL on the server? Link to comment Share on other sites More sharing options...
Intercepted Posted July 14, 2011 Author Share Posted July 14, 2011 It just wouldn't work here. I would have to run the PHP server myself and that's a little too much for this small task. By controlled environment I mean a government owned company. Everything on the computers are managed by the government. Google docs won't work because all our information needs to be within our network. Looks like I'll just have to teach the receptionist how to add new entries in HTML. Thanks for the responses Link to comment Share on other sites More sharing options...
thescientist Posted July 14, 2011 Share Posted July 14, 2011 I think we were missing some of what you were saying. If only one person is in charge of updating this directory file or whatever, then you can use a flat file. As long as all the other people just need to see the output, and not have to make any changes themselves, it will work. I think what was missing here was an accurate description of the problem at hand. User implies any random web user, meaning multiple people from all over the web. It appears to be in fact that the user is really just one static person, and that they will be the only one in charge of making the changes, correct? Link to comment Share on other sites More sharing options...
jeffman Posted July 14, 2011 Share Posted July 14, 2011 You would need to download the flat file through AJAX. Easily done. AJAX typically communicates with an executable, but it does not have to. Addressing a request object to a .txt file will simply return the text contents. Link to comment Share on other sites More sharing options...
Intercepted Posted July 15, 2011 Author Share Posted July 15, 2011 That's correct, only one person will be doing the editing. Sorry I'm completely oblivious to anything ajax. How would I use it to read and write information for my table from a flat file?EDIT: I'm playing around with this example right here: http://www.w3schools.com/ajax/ajax_xmlfile.aspbut I can't seem to get it working Link to comment Share on other sites More sharing options...
jeffman Posted July 15, 2011 Share Posted July 15, 2011 You'll want to read the AJAX tutorial. Be sure to do this tryit example. It practically does what you want right out out of the box. Link to comment Share on other sites More sharing options...
jeffman Posted July 15, 2011 Share Posted July 15, 2011 I'm playing around with this exampleThat's not the most useful example if you're not going to use XML. When we've referred to a flat file, I think we're assuming a list of tab-delimited values:Mary Lamb 555-1001Bob Smith 555-1002Tracy Byrd 555-1003 which is very easy to parse and iterate through. (Note: I enter tabs, but the board software converts them to spaces. I mean tabs, though.) Link to comment Share on other sites More sharing options...
Intercepted Posted July 15, 2011 Author Share Posted July 15, 2011 Just tried that example and I think our browsers are actually configured to block that kind of stuff. Using an exact copy of that AJAX example, IE gives me an access denied error on this line: xmlhttp.open("GET","ajax_info.txt",true); Link to comment Share on other sites More sharing options...
jeffman Posted July 15, 2011 Share Posted July 15, 2011 Be sure to upload the files to your server. Many browsers do not allow AJAX connections using your desktop file system. Link to comment Share on other sites More sharing options...
Intercepted Posted July 15, 2011 Author Share Posted July 15, 2011 Problem is we don't have a server running, the files are on a drive that is shared by the whole network. Link to comment Share on other sites More sharing options...
thescientist Posted July 15, 2011 Share Posted July 15, 2011 in the case of IE, you would have to manually change everyone's security setting, or just recommend people use a different browser. are people going to have manually open the pages themselves over the network, literally opening directory.html themselves? Link to comment Share on other sites More sharing options...
Intercepted Posted July 15, 2011 Author Share Posted July 15, 2011 That's right. Changing the internet explorer options is not an possible. The government controls those settings. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 15, 2011 Share Posted July 15, 2011 It sounds like Dreamweaver is in someone's future. You don't really have the tools available to automate this. Link to comment Share on other sites More sharing options...
Intercepted Posted July 15, 2011 Author Share Posted July 15, 2011 Seems that way. Thanks for all the help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.