Is it possible multiple submit button without refresh in a single form and pass data to designed page through database? I have a from(section.blade.php) in which I have 3 section one for man scheduled 2nd for women scheduled and 3rd for child scheduled and only one submit button, but I want on 3 submit button on form for each section, so I could post data like for men(1), women(1+) and child(1+) on single design page. Please tell or give any relevant link or example, Many Many thanks.
Asked
Active
Viewed 1,120 times
1
-
Use ajax to submit forms without refreshing the page. You need to have basic javascript/jquery knowledge to use ajax. Tutorial: https://hdtuto.com/article/jquery-ajax-post-request-example-in-laravel-57 – Disorder Aug 21 '19 at 06:40
-
1Possible duplicate of [Two submit buttons in one form](https://stackoverflow.com/questions/547821/two-submit-buttons-in-one-form) – Mr. Perfectionist Aug 21 '19 at 06:41
1 Answers
0
Have you tried ajax request and response? For example . When onclick event fired on button , make a function for onclick event .
I have added a code here .
Html
<button type ="button" onclick="licenseDelete(sendIdorAnyOtherValue);">
Click me to get value
</button>
JS
function LicenseDelete(Get the value) {
var img = key;
var d_id = $("#driv_id").val();
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
jQuery.ajax({
url: "{{ url('/vehicle/imgdestroy') }}",
method: 'post',
data: {
img : img,
d_id : d_id,
},
success: function(result){
var vehicle=JSON.parse(result);
console.log(vehicle);
//alert(result);
if(result){
toggleAlert();
}else{
$( "Failed . Try again" ).empty();
$("#send_id").attr("disabled", false);
}
}});
}

farooq
- 1,603
- 2
- 17
- 33
-
thanks @farooq, I have only one submit button on page and don't have more idea about ajax, can you give any example link? – user10945543 Aug 21 '19 at 06:37
-
And I am trying to submit the data for first form so that my page should not reload or refresh – user10945543 Aug 21 '19 at 10:23
-
That's why you need to use ajax. You should define the url in routes and and make a controller function to do the backend works. It will returns the output even without need to refresh the page . I prefer ajax for multiple form upload. – farooq Aug 21 '19 at 12:16
-
@user10945543 I love the design in your web page. You can use the ajax function for each forms. I would like to prefer this link for more info : https://appdividend.com/2018/02/07/laravel-ajax-tutorial-example/ please go through this page and try . :) – farooq Aug 21 '19 at 12:22
-
-