jandante@telenet.be Posted February 6, 2009 Share Posted February 6, 2009 Hi, I'm constructing a rather complex form (in my opinion ) to make it easy for a user to change his opening hours. The project I'm working on is a simple page with the opening hours of all the shops in our city. But it must be able for the shopkeeper to change his openinghours. To see it live: go to www.vinta.be => click on "Aanmelden" top right: login: testing pass: test then go to "Mijn Bedrijf" also top right, and next click on Openingsuren. You can see a table with openinghours. This is not working at all, it just displays the info from the database. What I would like to do now is check every time the user changes something in the table (he checks a checkbox/changes time) if the changes are correct made and if so it should directly back to the database and the form should reload. Do I need Ajax for that and if so where should I start? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
gaza165 Posted February 6, 2009 Share Posted February 6, 2009 You can either use AJAX i would recommend using JQuery Ajax, or you can use the onchange= method in html/javasript to trigger an event. Quote Link to comment Share on other sites More sharing options...
jandante@telenet.be Posted February 6, 2009 Author Share Posted February 6, 2009 So eitherway there will be a lot of code involved... Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 6, 2009 Share Posted February 6, 2009 If you want to update the form everyime a user changes something in the form, you can do this easiily with a submit form function in an onchange parameter on each input tag. This however could either a- get annoying having to wait for every single change to be checked and saved into the db. I would let them make all the changes they need, them have them tell the form "right, im done, save it please". This way, they make all the changes they need, and then they submit, php checks to make sure it all makes sense and if so saves it into the db. you can use ajax for this as well if you dont want to reload the 'whole' page, but this method is much easier and quicker using php to santize the variables etc, rather than relying on javascript/ajax code to make sure everything makes sense etc. hope this makes sense . PS: Basically all u need to do is keepo this form how it is, make a "Save Changes" button, rather than having a type='submit', have a type="button" with a onclick="ajax_function()"; then ajax_function() would be an "ajax function" that would handle sending the form the php and php giving information as it is saved or rejected (sanitized). -- Not really that much code Quote Link to comment Share on other sites More sharing options...
jandante@telenet.be Posted February 6, 2009 Author Share Posted February 6, 2009 The hard part for me is that the form should update after one clicks for example the Open checkbox. If that is clicked the rest of that line should become active. I suppose I will have to choose between this interactive mode written above or just let everything open to change and check for errors at the end. usability tells me the interactive mode is the best, but can i make the form reload after something is changed in the form Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.