How can I submit with 1 button and 1 form with 2 actions?
-
I have 2 pages. 1st is the index.php that have 3 fields. 2 of them should saved to sql and its works fine and the 3rd one should pass the value to 2nd screen. I have JS file. I success doing these 2 operations successfuly but in seperated projects. When I am trying to make them together there are mistakes. I want to know How can I implement those 2 parts together please. index.php
PHP MySQL Insert Tutorial Insert
2nd.php
minus
jS
$('#myform').submit(function(){
return false;
});$('#insert').click(function(){
$.post(
$('#myform').attr('action'),
$('#myform :input').serializeArray(),
function(result){
$('#result').php(result);
}
);
}); -
I have 2 pages. 1st is the index.php that have 3 fields. 2 of them should saved to sql and its works fine and the 3rd one should pass the value to 2nd screen. I have JS file. I success doing these 2 operations successfuly but in seperated projects. When I am trying to make them together there are mistakes. I want to know How can I implement those 2 parts together please. index.php
PHP MySQL Insert Tutorial Insert
2nd.php
minus
jS
$('#myform').submit(function(){
return false;
});$('#insert').click(function(){
$.post(
$('#myform').attr('action'),
$('#myform :input').serializeArray(),
function(result){
$('#result').php(result);
}
);
});One thing I see right away: your 2nd.php form submit's to index.php but the values you pass from the form are never looked for in index.php. So what's the point of that interaction?
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010