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); }
});
}
Save and add another function in php
Moderator: General Moderators
Re: Save and add another function in php
Okay... Any problems with it? Maybe you have a question to ask?
Re: Save and add another function in php
it didnt work...any codes i need to modify?
Re: Save and add another function in php
That's a bit vague. Could you elaborate?myra wrote:it didnt work
Re: Save and add another function in php
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
So about posting all your code rather than a couple pieces of it?
Re: Save and add another function in php
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.
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.