Save and add another function in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
myra
Forum Newbie
Posts: 3
Joined: Wed Dec 04, 2013 2:18 pm

Save and add another function in php

Post 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); }
});
}
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Save and add another function in php

Post by requinix »

Okay... Any problems with it? Maybe you have a question to ask?
myra
Forum Newbie
Posts: 3
Joined: Wed Dec 04, 2013 2:18 pm

Re: Save and add another function in php

Post by myra »

it didnt work...any codes i need to modify?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Save and add another function in php

Post by Celauran »

myra wrote:it didnt work
That's a bit vague. Could you elaborate?
myra
Forum Newbie
Posts: 3
Joined: Wed Dec 04, 2013 2:18 pm

Re: Save and add another function in php

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Save and add another function in php

Post by requinix »

So about posting all your code rather than a couple pieces of it?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Save and add another function in php

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply