Member Avatar for diafol

Hi all. Am messing about with an ajax form at present which loops through records in a DB. This is my issue:

I have a reset image link in my form (called "file_edit") which calls a 'confirm reset':

function reset() {
if (confirm("Reset? You'll lose any changes!")) {
	document.file_edit.reset();
   }
}

This works well. When I press prev/next buttons, my fields are updated programmatically via Ajax. I get values from DB and pass them back to js via json which then enters the data into the form fields. So in other words, only the values are replaced - not the actual form itself.

If I make changes to say the fifth record but then decide to reset the form, I am greeted by a return to the first record - not what I wanted.

Has anybody come across this problem, and if so, how do I ensure that I 'stay on the same record' on reset?

Not urgent. Thanks.

//EDIT
I suppose what I'm looking for is a sort of 'restore point' for the reset link. Perhaps I would be better off just reloading the current record? I know the reset form is controversial.

Member Avatar for diafol

I finally gave up on this as it caused more problem than it was worth - unless somebody can point me at a nice solution?

Have simply done a 'reload current record from DB'. Doh! Perhaps I was over-engineering the solution.

When someone clicks reset you could ajax the deletion of the current db record, or create a new one?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.