Within a view of Laravel, I generate a report and charge it using ajax. In the report I have three buttons, one of them is "Add".
Clicking on the "Add button does not redirect me to the route (viewAlarmasConfDestinatarios), in which I should show another form with fields that I must complete.
{{route ()}} does not work within ajax
ajax:
function fetch_data()
{
var trHTML ='';
$.ajax({
url: 'reporteAlarmasConfiguracion/',
type: "GET",
data : {"_token":"{{ csrf_token() }}"},
dataType: "json",
success:function(data)
{
if(data)
{
console.log('ENTRE AL FETCH_DATA');
$('#locationA > tbody').empty();
$.each(data, function(key, value)
{
var product_id = value.pais +'-'+ value.servicio +'-'+ value.denominacion;
var url = '{{ route("viewAlarmasConfDestinatarios.index", ":id") }}';
url = url.replace(':id',product_id);
console.log(url);
if($.trim(value.vigente) == '1')
{
console.log('ACTIVO');
value.vigente='<button type="button" class="btn btn-success btn-xs" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'">Activa</button>' ;
}
if($.trim(value.vigente) == '0')
{
value.vigente='<button type="button" class="btn btn-xs" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'"> Desactivada</button>' ;
}
if($.trim(value.pais) == '1')
{
value.pais='AR';
}
if($.trim(value.pais) == '2')
{
value.pais='UY';
}
if($.trim(value.pais) == '3')
{
value.pais='PY';
}
var data = {
"_token": $('#token').val()
};
var urlparm=value.pais +'-'+ value.servicio +'-'+ value.denominacion;
console.log(urlparm);
trHTML += '<tr id="fila"><td>' + value.pais + '</td><td>' + value.servicio + '</td><td>' + value.denominacion + '</td><td>' + value.descripcion + '</td><td>' + value.vigente + '</td><td>' + '<button type="button" class="btn btn-danger btn-xs delete" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'"> Eliminar</button> ' + '<button type="button" class="btn btn-warning btn-xs" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'"> Modificar</button>' + '</td><td>' + '<button type="button" class="btn btn-info btn-xs info"" id="'+ value.pais +'-'+ value.servicio +'-'+ value.denominacion+'" onclick="'+url+'">Cargar</button>' + '</td></tr>';
});
$('#locationA').append(trHTML);
}
}
});
}
route:
Route::get('/AlarmaConfDestinatarios/{denominacion?}', 'alarmasController#viewAlarmasConfDestinatarios')->name('viewAlarmasConfDestinatarios.index');
image
Try using {{route()}} within double inverted quotes like:
var url = "{{ route('viewAlarmasConfDestinatarios.index', ':id') }}";
Related
please help me solve this error
i tried too much but it still returns an error i don't know why please help
it returns Uncaught SyntaxError: missing ) after argument list at line that contains
<td>' + item.name + '</td>\
here is my code
<script>
$(document).ready(function(){
fetchpost();
function fetchpost() {
$.ajax({
type: "GET",
url: "/fetchpost",
dataType: "json",
success: function (response) {
// console.log(response);
$('tbody').html("");
$.each(response.posts, function (key, item) {
$('tbody').append('<tr>\
<td>' + item.id + '</td>\
<td>' + item.name + '</td>\
<td>show</td>\
<td><button type="button" value="' + item.id + '" class="btn btn-primary editbtn btn-sm">Edit</button></td>\
<td><button type="button" value="' + item.id + '" class="btn btn-danger deletebtn btn-sm">Delete</button></td>\
\</tr>');
});
}
});
}
})
you forgot to concat the string <td>show</td>\
Anyway try with this code:
$(document).ready(function(){
fetchpost();
function fetchpost() {
$.ajax({
type: "GET",
url: "/fetchpost",
dataType: "json",
success: function (response) {
// console.log(response);
$('tbody').html("");
$.each(response.posts, function (key, item) {
$('tbody').append('<tr>\
<td>' + item.id + '</td>\
<td>' + item.name + '</td>\
<td>show</td>\
<td><button type="button" value="' + item.id + '" class="btn btn-primary editbtn btn-sm">Edit</button></td>\
<td><button type="button" value="' + item.id + '" class="btn btn-danger deletebtn btn-sm">Delete</button></td>\
\</tr>');
});
}
});
}
})
I tried using this ("#refresh").load(document.URL + "#refresh") but it only works for 1 data in a for each loop, I was wondering if there is a way like to click a button and change its value from "Read" to Unread"
view.php
<button type='button' class='btn btn-sm btn-danger btn-mar' data-id='{{ $complaint->uniquekey }}' aria-hidden='true' >
<div class="ref{{ $complaint->id }}" id="refresh">
{{ $complaint->status == 'unread' ? 'Read' : 'Unread' }}
</div>
</button>
this is my script
$(document).on("click",'.btn-mar', function(t) {
t.preventDefault();
var $this = $(this);
var id = $this.data('id');
var refresh = $("#refresh").attr('class');
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: '{{ route('complaints.mar') }}',
method:"POST",
data: {uniquekey:id},
beforeSend: function(){
alert(id);
},
success: function(t) {
$(refresh).attr('class').load(document.URL + refresh);
},
error: function(t) {
alert("Internal Server Error");
}
});
});
Okay so instead of using a div for me to use, I use this
if($('#'+id).html()=="Unread"){
$('#'+id).html('Read');
}
else{
$('#'+id).html('Unread');
}
and then change the
<button type='button' class='btn btn-sm btn-danger btn-mar' data-id='{{ $complaint->uniquekey }}' aria-hidden='true' >
<div class="ref{{ $complaint->id }}" id="refresh">
{{ $complaint->status == 'unread' ? 'Read' : 'Unread' }}
</div>
</button>
To
<button type='button' id="{{ $complaint->uniquekey }}" class='btn btn-sm btn-danger btn-mar' data-id='{{ $complaint->uniquekey }}' aria-hidden='true' >
{{ $complaint->status }}
</button>
I am display success message in div of id=ajax-alert but my aim is to display this message in popup and after displaying this message in within some time popup will hide. I am confused how i am display success message in popup. How i am creating popup and how it is disable in some time?
View:
<div id="ajax-alert" class="alert" style="display:none"></div>
controller:
public function add_to_wishlist(Request $req)
{
$userId=Session::get('userid');
if(empty($userId))
{
return response()->json(['status'=> 1]);
}
else
{
$checkWishlist=DB::select('select * from wishlist where user_id=? && product_id=?',[$userId,$req->sub_id]);
if($checkWishlist)
{
DB::table('wishlist')->where('user_id',$userId)->where('product_id',$req->sub_id)->delete();
return response()->json(['status'=> 2,'message'=>'item is removed from wishlist']);
}
else
{
DB::table('wishlist')->insert(['user_id'=>$userId,'product_id'=>$req->sub_id]);
return response()->json(['status'=> 3,'message'=>'item is added in wishlist']);
}
}
}
script:
<script type="text/javascript">
$(document).ready(function(){
$('.sub').click(function(e) {
var sub_id=$(this).attr('data-id');
var input=$(this).prev();
e.preventDefault()
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
}
});
jQuery.ajax({
url: "{{ url('/add-to-wishlist') }}",
method: 'get',
data: {
sub_id: sub_id,
},
success: function(result){
if(result.status==1)
{
window.location.href="/login";
}
else if(result.status==2)
{
//$('a[data-id="' + sub_id + '"] > i.whishstate').css({"color":"grey"});
$('a[data-id="' + sub_id + '"] > i.whishstate').removeClass("add");
$('a[data-id="' + sub_id + '"] > i.whishstate').addClass("remove");
$('#ajax-alert').addClass('alert-success').show(function(){
$(this).html(result.message);
});
}
else if(result.status==3)
{
//$('a[data-id="' + sub_id + '"] > i.whishstate').css({"color":"#FBA842"});
$('a[data-id="' + sub_id + '"] > i.whishstate').removeClass("remove");
$('a[data-id="' + sub_id + '"] > i.whishstate').addClass("add");
$('#ajax-alert').addClass('alert-success').show(function(){
$(this).html(result.message);
});
}
}});
});
});
</script>
#endsection
in ajax you can not use $(this)
it's not getting you any errors or warning~, it just does not working
you can do this:
<script type="text/javascript">
$(document).ready(function(){
$('.sub').click(function(e) {
var this_element = $(this); //THIS LINE ADDED!
var sub_id=$(this).attr('data-id');
var input=$(this).prev();
e.preventDefault()
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
}
});
jQuery.ajax({
url: "{{ url('/add-to-wishlist') }}",
method: 'get',
data: {
sub_id: sub_id,
},
success: function(result){
if(result.status==1)
{
window.location.href="/login";
}
else if(result.status==2)
{
//$('a[data-id="' + sub_id + '"] > i.whishstate').css({"color":"grey"});
$('a[data-id="' + sub_id + '"] > i.whishstate').removeClass("add");
$('a[data-id="' + sub_id + '"] > i.whishstate').addClass("remove");
$('#ajax-alert').addClass('alert-success').show(function(){
this_element.html(result.message);
}); //THIS LINE CHANGED!
}
else if(result.status==3)
{
//$('a[data-id="' + sub_id + '"] > i.whishstate').css({"color":"#FBA842"});
$('a[data-id="' + sub_id + '"] > i.whishstate').removeClass("remove");
$('a[data-id="' + sub_id + '"] > i.whishstate').addClass("add");
$('#ajax-alert').addClass('alert-success').show(function(){
this_element.html(result.message);
}); //THIS LINE CHANGED TOO!
}
}});
});
});
</script>
To display a popup, you can use a Modal. You can use this basic modal to use as your popup:
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p class = 'alert-text'></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('.sub').click(function(e) {
var $this = $(this);
var sub_id= $this.attr('data-id');
var input= $this.prev();
e.preventDefault()
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
}
});
jQuery.ajax({
url: "{{ url('/add-to-wishlist') }}",
method: 'get',
data: {
sub_id: sub_id,
},
success: function(result){
if(result.status == 1) {
window.location.href="/login";
}
else if(result.status == 2) {
//$('a[data-id="' + sub_id + '"] > i.whishstate').css({"color":"grey"});
$('a[data-id="' + sub_id + '"] > i.whishstate').removeClass("add");
$('a[data-id="' + sub_id + '"] > i.whishstate').addClass("remove");
$('.alert-text').html(result.message);
$('#myModal').modal('show');
}
else if(result.status == 3) {
//$('a[data-id="' + sub_id + '"] > i.whishstate').css({"color":"#FBA842"});
$('a[data-id="' + sub_id + '"] > i.whishstate').removeClass("remove");
$('a[data-id="' + sub_id + '"] > i.whishstate').addClass("add");
$('.alert-text').html(result.message);
$('#myModal').modal('show');
setTimeout(function(){
$('#myModal').modal('hide');
},3000); //It will hide modal
}
}});
});
});
</script>
If you want more custom popup then you can search for sweetAlert.
// install package
composer require brian2694/laravel-toastr
// then
php artisan vendor:publish
// use this css cdn
<link rel="stylesheet" href="http://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css">
// use this js cdn
<script src="http://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
{!! Toastr::message() !!}
<script>
#if($errors->any())
#foreach($errors->all() as $error)
toastr.error('{{ $error }}','Error',{
closeButton:true,
progressBar:true,
});
#endforeach
#endif
</script>
// Controller
use Brian2694\Toastr\Facades\Toastr;
public function store(Request $request)
{
$this->validate($request,[
'name' => 'required'
]);
$category = new Category();
$category->name = $request->name;
$category->slug = str_slug($request->name);
$category->save();
Toastr::success('Category Successfully Saved','Success');
return redirect()->route('admin.category.index');
}
I am working on a survey application with Asp.Net MVC. I have a page named Index.cshtml which has a question table and a 'Add New' button.Once button clicked, a popup is opened with jQuery. I am calling a view from controller to fill jQuery dialog named as AddOrEdit.cshtml (child page). I am adding new question and options. Question is a textfield and its options are added in editable table. Once clicked submt button Submit form event (save or update) is fired. But ajax sends twice request. One of these requests send empty object, the other sends full object. Where am I making a mistake?
According to my research, what causes this problem is that the unobtrusive validator is placed on 2 different pages. But this is not the case for me.
When I debug with chrome in f12, the initiator of one of the 2 requests 'jquery' the initiator of the other 'other' The type of one of these 2 post requests appears as 'XHR' and the type of the other is 'document'.
Index.cshtml
#{
ViewBag.Title = "Soru Listesi";
}
<h2>Soru Oluşturma</h2>
<a class="btn btn-success" style="margin-bottom: 10px"
onclick="PopupForm('#Url.Action("AddOrEdit","Question")')"><i class="fa fa-plus"></i> Yeni Soru Oluştur</a><table id="questionTable" class="table table-striped table-bordered accent-blue" style="width: 100%">
<thead>
<tr>
<th>Soru No</th>
<th>Soru Adı</th>
<th>Oluşturma Tarihi</th>
<th>Güncelleme Tarihi</th>
<th>Güncelle/Sil</th>
</tr>
</thead>
</table>
<link
href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel="stylesheet" />
#section Scripts{
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap4.min.js"></script>
<script>
var Popup, dataTable;
$(document).ready(function() {
dataTable = $("#questionTable").DataTable({
"ajax": {
"url": "/Question/GetData",
"type": "GET",
"datatype": "json"
},
"columnDefs": [
{ targets: 2 }
],
"scrollX": true,
"scrollY": "auto",
"columns": [
{ "data": "QuestionId" },
{ "data": "QuestionName" },
{
"data": "CreatedDate",
"render": function(data) { return getDateString(data); }
},
{
"data": "UpdatedDate",
"render": function(data) { return getDateString(data); }
},
{
"data": "QuestionId",
"render": function(data) {
return "<a class='btn btn-primary btn-sm' onclick=PopupForm('#Url.Action("AddOrEdit", "Question")/" +
data +
"')><i class='fa fa-pencil'></i> Güncelle</a><a class='btn btn-danger btn-sm' style='margin-left:5px' onclick=Delete(" +
data +
")><i class='fa fa-trash'></i> Sil</a>";
},
"orderable": false,
"searchable": false,
"width": "150px"
}
],
"language": {
"emptyTable":
"Soru bulunamadı, lütfen <b>Yeni Soru Oluştur</b> butonuna tıklayarak yeni soru oluşturunuz. "
}
});
});
function getDateString(date) {
var dateObj = new Date(parseInt(date.substr(6)));
let year = dateObj.getFullYear();
let month = (1 + dateObj.getMonth()).toString().padStart(2, '0');
let day = dateObj.getDate().toString().padStart(2, '0');
return day + '/' + month + '/' + year;
};
function PopupForm(url) {
var formDiv = $('<div/>');
$.get(url)
.done(function(response) {
formDiv.html(response);
Popup = formDiv.dialog({
autoOpen: true,
resizable: true,
title: 'Soru Detay',
modal: true,
height: 'auto',
width: '700',
close: function() {
Popup.dialog('destroy').remove();
}
});
});
}
function SubmitForm(form) {
debugger;
if (form.checkValidity() === false) {
debugger;
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
if ($(form).valid()) {
var question = {};
question.questionId = 1111;
var options = new Array();
$("#questionForm TBODY TR").each(function() {
var row = $(this);
var option = {};
option.OptionId = row.find("TD").eq(0).html();
option.OptionName = row.find("TD").eq(1).html();
options.push(option);
});
question.options = options;
question.responses = new Array();
$.ajax({
type: "POST",
url: form.action,
data: JSON.stringify(question),
success: function(data) {
if (data.success) {
debugger;
Popup.dialog('close');
dataTable.ajax.reload();
$.notify(data.message,
{
globalPosition: "top center",
className: "success",
showAnimation: "slideDown",
gap: 1000
});
}
},
error: function(req, err) {
debugger;
alert('req : ' + req + ' err : ' + err.data);
},
complete: function(data) {
alert('complete : ' + data.status);
}
});
}
}
function ResetForm(form) {
Popup.dialog('close');
return false;
}
function Delete(id) {
if (confirm('Bu soruyu silmek istediğinizden emin misiniz?')) {
$.ajax({
type: "POST",
url: '#Url.Action("Delete", "Question")/' + id,
success: function(data) {
if (data.success) {
dataTable.ajax.reload();
$.notify(data.message,
{
className: "success",
globalPosition: "top center",
title: "BAŞARILI"
})
}
}
});
}
}
</script>
}
AddOrEdit.cshtml
#using MerinosSurvey.Models
#model Questions
#{
Layout = null;
}
#using (Html.BeginForm("AddOrEdit", "Question", FormMethod.Post, new { #class = "needs-validation",
novalidate = "true", onsubmit = "return SubmitForm(this)", onreset = "return ResetForm(this)", id =
"questionForm" }))
{
<div class="form-group row">
#Html.Label("QuestionId", "Soru No", new { #class = "col-form-label col-md-3" })
<div class="col-md-9">
#Html.TextBoxFor(model => model.QuestionId, new { #readonly = "readonly", #class = "form-control" })
</div>
</div>
<div class="form-group row">
#Html.Label("QuestionName", "Soru Adı", new { #class = "col-form-label col-md-3" })
<div class="col-md-9">
#Html.EditorFor(model => model.QuestionName, new { htmlAttributes = new { #class = "form-control", required = "true" } })
<div class="valid-feedback"><i class="fa fa-check">Süpersin</i></div>
<div class="invalid-feedback "><i class="fa fa-times"></i></div>
</div>
</div>
#*<div class="form-group row">
#Html.LabelFor(model => model.CreatedDate, new { #class = "form-control-label col-md-3"})
<div class="col-md-9">
#Html.EditorFor(model => model.CreatedDate, "{0:yyyy-MM-dd}", new { htmlAttributes = new { #class = "form-control", type = "date", #readonly = "readonly",required="false" } })
</div>
</div>*#
<div class="table-wrapper form-group table-responsive-md">
<div class="table-title">
<div class="form-group row">
<div class="col-md-9">Seçenekler</div>
<div class="col-md-3">
<a class="btn btn-success add-new" style="margin-bottom: 10px"><i class="fa fa-plus"></i>Seçenek Ekle</a>
</div>
</div>
</div>
<table class="table optionTable">
<thead>
<tr>
<th scope="col">Seçenek Id</th>
<th scope="col">Seçenek Adı</th>
<th scope="col">Güncelle/Sil</th>
</tr>
</thead>
<tbody>
#*#foreach (Options options in Model.Options)
{
<tr>
<td>#options.OptionId</td>
<td>#options.OptionName</td>
<td>
<a class="add btn btn-primary btn-sm" title="Add" data-toggle="tooltip">
<i class="fa fa-check">Onayla</i></a>
<a class="edit btn btn-secondary btn-sm" title="Edit" data-toggle="tooltip"><i class="fa fa-pencil">Güncelle</i></a>
<a class="delete btn-danger btn-sm" title="Delete" data-toggle="tooltip"><i class="fa fa-trash">Sil</i></a>
</td>
</tr>
}*#
</tbody>
</table>
</div>
<div class="form-group row">
<input type="submit" value="Submit" class="btn btn-primary" id="btnSubmit" />
<input type="reset" value="Reset" class="btn btn-secondary" />
</div>
}
<script>
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
//var actions = $("table.optionTable td:last-child").html();
var actions =' <a class="add btn btn-primary btn-sm" title="Add" data-toggle="tooltip"><i
class="fa fa-check">Onayla</i></a>' + '<a class="edit btn btn-secondary btn-sm" title="Edit" data toggle="tooltip"><i class="fa fa-pencil">Güncelle</i></a>' +'<a class="delete btn-danger btn-sm" title="Delete" data-toggle="tooltip"><i class="fa fa-trash">Sil</i></a>';
// Append table with add row form on add new button click
$(".add-new").click(function () {
$(this).attr("disabled", "disabled");
var index = $("table.optionTable tbody tr:last-child").index();
var row = '<tr>' +
'<td><input type="text" class="form-control" name="optionId" id="optionId"></td>' +
'<td><input type="text" class="form-control" name="optionId" id="optionName"></td>' +
'<td>' + actions + '</td>' +
'</tr>';
$("table.optionTable").append(row);
$("table.optionTable tbody tr").eq(index + 1).find(".add, .edit").toggle();
$('[data-toggle="tooltip"]').tooltip();
});
// Add row on add button click
$(document).on("click", ".add", function () {
var empty = false;
var input = $(this).parents("tr").find('input[type="text"]');
input.each(function () {
if (!$(this).val()) {
$(this).addClass("error");
empty = true;
} else {
$(this).removeClass("error");
}
});
$(this).parents("tr").find(".error").first().focus();
if (!empty) {
input.each(function () {
$(this).parent("td").html($(this).val());
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".add-new").removeAttr("disabled");
}
});
// Edit row on edit button click
$(document).on("click", ".edit", function () {
$(this).parents("tr").find("td:not(:last-child)").each(function () {
$(this).html('<input type="text" class="form-control" value="' + $(this).text() + '">');
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".add-new").attr("disabled", "disabled");
});
// Delete row on delete button click
$(document).on("click", ".delete", function () {
debugger;
$(this).parents("tr").remove();
$(".add-new").removeAttr("disabled");
});
});
event.preventDefault(); move this line and place it immediately after function SubmitForm (form){
Like below:
function SubmitForm(form) {
debugger;
event.preventDefault();
if (form.checkValidity() === false) {
debugger;
event.stopPropagation();
}
form.classList.add('was-validated');
if ($(form).valid()) {
var question = {};
question.questionId = 1111;
var options = new Array();
$("#questionForm TBODY TR").each(function() {
var row = $(this);
var option = {};
option.OptionId = row.find("TD").eq(0).html();
option.OptionName = row.find("TD").eq(1).html();
options.push(option);
});
question.options = options;
question.responses = new Array();
$.ajax({
type: "POST",
url: form.action,
data: JSON.stringify(question),
success: function(data) {
if (data.success) {
debugger;
Popup.dialog('close');
dataTable.ajax.reload();
$.notify(data.message,
{
globalPosition: "top center",
className: "success",
showAnimation: "slideDown",
gap: 1000
});
}
},
error: function(req, err) {
debugger;
alert('req : ' + req + ' err : ' + err.data);
},
complete: function(data) {
alert('complete : ' + data.status);
}
});
}
}
ajax
$(document).ready(function(){
tabel_sales = $('#tabel_sales').DataTable({
'bLengthChange': false,
scrollXInner: true,
dom : 'frtp',
processing : true,
serverside : true,
ajax : {
'url' : '{{ url("data/data_sales") }}',
'data' : function(data){
month = $('#month').val();
console.log(data);
data.searchByMonth = month;
}
}
})
$('#month').change(function(e){
tabel_sales.draw();
})
})
controller
$testing = $request->get('searchByMonth');
$get_po_apar = DB::table('tabel_header_po')
->where([
['kode_mitra', Auth::user()->kode_mitra],
['no_po', 'LIKE', '%TRX%'],
['created_by', $gd->kode_user]
])
->whereMonth('created_at',$testing)
->get();
if (count($get_po_apar) > 0) {
$po = '<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-envelope"></i> ' . count($get_po_apar) . ' Po Apar</button>';
$fetch[] = $po;
} else {
$po = '<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-envelope"></i> 0 Po Apar</button>';
$fetch[] = $po;
}
i have problem, I want to display data based on the month dropdown I chose, automatically the data that appears will change based on the dropdown
please Help me!
You can try using:
tabel_sales.columns("index column" or "column name").search("value").draw();
This link: https://datatables.net/reference/api/column().search()
May I help you!