Page 1 of 1

Save and add another function in php

Posted: Wed Dec 04, 2013 2:30 pm
by myra
Currently what we have is a html form in customerproblem.php, when the customer fills the form and click save it will be directed to saveproblem.php where the problem will be assigned to concerned department and once it is assigned it will be redirected to home page. So what we need now is one new button called "save and add another" in customerproblem.php which when click will save the form info and reset the form to allow users to add new info, without redirecting to saveproblem.php. And finally when customer click save button, all the added information will be appended in text field that is in saveproblem.php.

What I tried was:

frmAdd has this code (there are other codes as well)

<input type="button" value="Save and add another" onclick="save()"

and i call a function save on click


function save(){
$.ajax({
type: "POST",
url: "saveproblem.php,
data: jQuery("#frmAdd").serialize(),
cache: false,
success: function(data){
alert("Savings has been updated successfully.");
window.location.reload(true); }
});
}

Re: Save and add another function in php

Posted: Wed Dec 04, 2013 3:22 pm
by requinix
Okay... Any problems with it? Maybe you have a question to ask?

Re: Save and add another function in php

Posted: Wed Dec 04, 2013 3:41 pm
by myra
it didnt work...any codes i need to modify?

Re: Save and add another function in php

Posted: Wed Dec 04, 2013 4:34 pm
by Celauran
myra wrote:it didnt work
That's a bit vague. Could you elaborate?

Re: Save and add another function in php

Posted: Wed Dec 04, 2013 4:43 pm
by myra
When clicked, save and add button , there is no response. nothing changes. May be you can suggest me other way of doing it.

Re: Save and add another function in php

Posted: Wed Dec 04, 2013 6:13 pm
by requinix
So about posting all your code rather than a couple pieces of it?

Re: Save and add another function in php

Posted: Fri Dec 06, 2013 4:33 pm
by pickle
If a customer has multiple problems, wouldn't you want each problem to be submitted separately?

If you have 2 submit buttons named, for example "submit" and "submit_return", you can do logic in your saveproblems.php page so that if "submit_return" is found in $_POST, then you forward the user back to customerproblem.php. If "submit" is found, you forward the user back to the homepage. A single form can have multiple submit buttons. Only the button clicked will be present in $_POST.