Phalcon PHP: Select option value POST in table using DataTable
up vote
1
down vote
favorite
I have a problem in getting the value in my field, I am using DataTable for my table.
My error is , the selected value is not posting in table.
here's my code...
NOTE: I'm using Phalocon PHP , DataTable API for phalcon.
here's my controller :
public function orderWalkinAction()
{
$this->view->disable();
if($this->request->isPost()) {
$arr = array();
$dropdown_id = $this->request->getPost('dropdown_id', 'striptags');
$select_orderitems_query = Medics::find(
[
"conditions" => "medID = :id: AND status = 'ACTIVE'",
"bind" =>
[
"id" => $dropdown_id,
]
]
);
foreach ($select_orderitems_query as $data_orderItem) {
$orderitem_medID = $data_orderItem->medID;
$orderitem_code = $data_orderItem->itemcode;
$orderitem_name = $data_orderItem->itemname;
$orderitem_brand = $data_orderItem->itembrand;
$orderitem_quan = $data_orderItem->itemquan;
$orderitem_price = $data_orderItem->itemprice;
$orderitem_totalprice = $data_orderItem->totalPrice;
$arr = array(
"itemcode" => $orderitem_code,
"itemname" => $orderitem_name."-".$orderitem_brand,
"itemquan" => $orderitem_quan,
"itemprice" => $orderitem_price,
"total" => $orderitem_totalprice,
"action" => "<button class='btn btn-danger' id='orderRecord-delete' data-id='".$orderitem_medID."'><i class='fa fa-trash'></i></button>"
);
}
$dataTables = new DataTable();
$dataTables->fromArray($arr)->sendResponse();
}
}
Here's my Js
$(document).on('change', '#items', function(e) {
e.preventDefault();
var dropdown_val = $(this).val();
if(dropdown_val != null)
{
//Table For Order Items
$('#order_tbl').DataTable({
processing: true,
deferRender: true,
ajax: {
url: '/HPsys/walkin/orderWalkin',
method: 'POST',
data: { dropdown_id : dropdown_val }
},
columns: [
{ data : "itemcode" },
{ data : "itemname" },
{ data : "itemquan" },
{ data : "itemprice" },
{ data : "total" },
{ data : "action" },
]
});
}
else
{
}
});
Here's my View
<select class="form-control" id="items">
<option value="">-- Select Item --</option>
</select>
<hr>
<h2 class="text-center">Order Details </h2>
<table class="table" id="order_tbl">
<thead>
<tr>
<th>Item Code</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
<th>Action</th>
</tr>
</thead>
</table>
If there's a vlog/tutorial/ or any recommendation please feel free to comment, I really appreciate that.
javascript mysql phalcon
|
show 10 more comments
up vote
1
down vote
favorite
I have a problem in getting the value in my field, I am using DataTable for my table.
My error is , the selected value is not posting in table.
here's my code...
NOTE: I'm using Phalocon PHP , DataTable API for phalcon.
here's my controller :
public function orderWalkinAction()
{
$this->view->disable();
if($this->request->isPost()) {
$arr = array();
$dropdown_id = $this->request->getPost('dropdown_id', 'striptags');
$select_orderitems_query = Medics::find(
[
"conditions" => "medID = :id: AND status = 'ACTIVE'",
"bind" =>
[
"id" => $dropdown_id,
]
]
);
foreach ($select_orderitems_query as $data_orderItem) {
$orderitem_medID = $data_orderItem->medID;
$orderitem_code = $data_orderItem->itemcode;
$orderitem_name = $data_orderItem->itemname;
$orderitem_brand = $data_orderItem->itembrand;
$orderitem_quan = $data_orderItem->itemquan;
$orderitem_price = $data_orderItem->itemprice;
$orderitem_totalprice = $data_orderItem->totalPrice;
$arr = array(
"itemcode" => $orderitem_code,
"itemname" => $orderitem_name."-".$orderitem_brand,
"itemquan" => $orderitem_quan,
"itemprice" => $orderitem_price,
"total" => $orderitem_totalprice,
"action" => "<button class='btn btn-danger' id='orderRecord-delete' data-id='".$orderitem_medID."'><i class='fa fa-trash'></i></button>"
);
}
$dataTables = new DataTable();
$dataTables->fromArray($arr)->sendResponse();
}
}
Here's my Js
$(document).on('change', '#items', function(e) {
e.preventDefault();
var dropdown_val = $(this).val();
if(dropdown_val != null)
{
//Table For Order Items
$('#order_tbl').DataTable({
processing: true,
deferRender: true,
ajax: {
url: '/HPsys/walkin/orderWalkin',
method: 'POST',
data: { dropdown_id : dropdown_val }
},
columns: [
{ data : "itemcode" },
{ data : "itemname" },
{ data : "itemquan" },
{ data : "itemprice" },
{ data : "total" },
{ data : "action" },
]
});
}
else
{
}
});
Here's my View
<select class="form-control" id="items">
<option value="">-- Select Item --</option>
</select>
<hr>
<h2 class="text-center">Order Details </h2>
<table class="table" id="order_tbl">
<thead>
<tr>
<th>Item Code</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
<th>Action</th>
</tr>
</thead>
</table>
If there's a vlog/tutorial/ or any recommendation please feel free to comment, I really appreciate that.
javascript mysql phalcon
@Phil yeah sure, my bad.
– koroku
Nov 20 at 5:39
What debugging have you done? I'd start by looking in the browser's Network console... inspect the AJAX request and check what data its sending? FYI, you have no useful<option>
elements in your<select>
so I'm not sure what sort of value you expect
– Phil
Nov 20 at 5:41
@Phil in my<option>
I append the dropdown using javascript , then what I am expecting is when I select one of the value in my<select>
it will appear in my DataTable
– koroku
Nov 20 at 5:45
So, about that Network console...
– Phil
Nov 20 at 5:46
1
@Phil ohh.. sorry my bad, my error only is the url of the API i used in dataTable for phalcon. I just review the documentation of that API then I get to that. that's it.
– koroku
Nov 22 at 1:28
|
show 10 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a problem in getting the value in my field, I am using DataTable for my table.
My error is , the selected value is not posting in table.
here's my code...
NOTE: I'm using Phalocon PHP , DataTable API for phalcon.
here's my controller :
public function orderWalkinAction()
{
$this->view->disable();
if($this->request->isPost()) {
$arr = array();
$dropdown_id = $this->request->getPost('dropdown_id', 'striptags');
$select_orderitems_query = Medics::find(
[
"conditions" => "medID = :id: AND status = 'ACTIVE'",
"bind" =>
[
"id" => $dropdown_id,
]
]
);
foreach ($select_orderitems_query as $data_orderItem) {
$orderitem_medID = $data_orderItem->medID;
$orderitem_code = $data_orderItem->itemcode;
$orderitem_name = $data_orderItem->itemname;
$orderitem_brand = $data_orderItem->itembrand;
$orderitem_quan = $data_orderItem->itemquan;
$orderitem_price = $data_orderItem->itemprice;
$orderitem_totalprice = $data_orderItem->totalPrice;
$arr = array(
"itemcode" => $orderitem_code,
"itemname" => $orderitem_name."-".$orderitem_brand,
"itemquan" => $orderitem_quan,
"itemprice" => $orderitem_price,
"total" => $orderitem_totalprice,
"action" => "<button class='btn btn-danger' id='orderRecord-delete' data-id='".$orderitem_medID."'><i class='fa fa-trash'></i></button>"
);
}
$dataTables = new DataTable();
$dataTables->fromArray($arr)->sendResponse();
}
}
Here's my Js
$(document).on('change', '#items', function(e) {
e.preventDefault();
var dropdown_val = $(this).val();
if(dropdown_val != null)
{
//Table For Order Items
$('#order_tbl').DataTable({
processing: true,
deferRender: true,
ajax: {
url: '/HPsys/walkin/orderWalkin',
method: 'POST',
data: { dropdown_id : dropdown_val }
},
columns: [
{ data : "itemcode" },
{ data : "itemname" },
{ data : "itemquan" },
{ data : "itemprice" },
{ data : "total" },
{ data : "action" },
]
});
}
else
{
}
});
Here's my View
<select class="form-control" id="items">
<option value="">-- Select Item --</option>
</select>
<hr>
<h2 class="text-center">Order Details </h2>
<table class="table" id="order_tbl">
<thead>
<tr>
<th>Item Code</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
<th>Action</th>
</tr>
</thead>
</table>
If there's a vlog/tutorial/ or any recommendation please feel free to comment, I really appreciate that.
javascript mysql phalcon
I have a problem in getting the value in my field, I am using DataTable for my table.
My error is , the selected value is not posting in table.
here's my code...
NOTE: I'm using Phalocon PHP , DataTable API for phalcon.
here's my controller :
public function orderWalkinAction()
{
$this->view->disable();
if($this->request->isPost()) {
$arr = array();
$dropdown_id = $this->request->getPost('dropdown_id', 'striptags');
$select_orderitems_query = Medics::find(
[
"conditions" => "medID = :id: AND status = 'ACTIVE'",
"bind" =>
[
"id" => $dropdown_id,
]
]
);
foreach ($select_orderitems_query as $data_orderItem) {
$orderitem_medID = $data_orderItem->medID;
$orderitem_code = $data_orderItem->itemcode;
$orderitem_name = $data_orderItem->itemname;
$orderitem_brand = $data_orderItem->itembrand;
$orderitem_quan = $data_orderItem->itemquan;
$orderitem_price = $data_orderItem->itemprice;
$orderitem_totalprice = $data_orderItem->totalPrice;
$arr = array(
"itemcode" => $orderitem_code,
"itemname" => $orderitem_name."-".$orderitem_brand,
"itemquan" => $orderitem_quan,
"itemprice" => $orderitem_price,
"total" => $orderitem_totalprice,
"action" => "<button class='btn btn-danger' id='orderRecord-delete' data-id='".$orderitem_medID."'><i class='fa fa-trash'></i></button>"
);
}
$dataTables = new DataTable();
$dataTables->fromArray($arr)->sendResponse();
}
}
Here's my Js
$(document).on('change', '#items', function(e) {
e.preventDefault();
var dropdown_val = $(this).val();
if(dropdown_val != null)
{
//Table For Order Items
$('#order_tbl').DataTable({
processing: true,
deferRender: true,
ajax: {
url: '/HPsys/walkin/orderWalkin',
method: 'POST',
data: { dropdown_id : dropdown_val }
},
columns: [
{ data : "itemcode" },
{ data : "itemname" },
{ data : "itemquan" },
{ data : "itemprice" },
{ data : "total" },
{ data : "action" },
]
});
}
else
{
}
});
Here's my View
<select class="form-control" id="items">
<option value="">-- Select Item --</option>
</select>
<hr>
<h2 class="text-center">Order Details </h2>
<table class="table" id="order_tbl">
<thead>
<tr>
<th>Item Code</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
<th>Action</th>
</tr>
</thead>
</table>
If there's a vlog/tutorial/ or any recommendation please feel free to comment, I really appreciate that.
javascript mysql phalcon
javascript mysql phalcon
edited Nov 20 at 5:41
asked Nov 20 at 5:26
koroku
136
136
@Phil yeah sure, my bad.
– koroku
Nov 20 at 5:39
What debugging have you done? I'd start by looking in the browser's Network console... inspect the AJAX request and check what data its sending? FYI, you have no useful<option>
elements in your<select>
so I'm not sure what sort of value you expect
– Phil
Nov 20 at 5:41
@Phil in my<option>
I append the dropdown using javascript , then what I am expecting is when I select one of the value in my<select>
it will appear in my DataTable
– koroku
Nov 20 at 5:45
So, about that Network console...
– Phil
Nov 20 at 5:46
1
@Phil ohh.. sorry my bad, my error only is the url of the API i used in dataTable for phalcon. I just review the documentation of that API then I get to that. that's it.
– koroku
Nov 22 at 1:28
|
show 10 more comments
@Phil yeah sure, my bad.
– koroku
Nov 20 at 5:39
What debugging have you done? I'd start by looking in the browser's Network console... inspect the AJAX request and check what data its sending? FYI, you have no useful<option>
elements in your<select>
so I'm not sure what sort of value you expect
– Phil
Nov 20 at 5:41
@Phil in my<option>
I append the dropdown using javascript , then what I am expecting is when I select one of the value in my<select>
it will appear in my DataTable
– koroku
Nov 20 at 5:45
So, about that Network console...
– Phil
Nov 20 at 5:46
1
@Phil ohh.. sorry my bad, my error only is the url of the API i used in dataTable for phalcon. I just review the documentation of that API then I get to that. that's it.
– koroku
Nov 22 at 1:28
@Phil yeah sure, my bad.
– koroku
Nov 20 at 5:39
@Phil yeah sure, my bad.
– koroku
Nov 20 at 5:39
What debugging have you done? I'd start by looking in the browser's Network console... inspect the AJAX request and check what data its sending? FYI, you have no useful
<option>
elements in your <select>
so I'm not sure what sort of value you expect– Phil
Nov 20 at 5:41
What debugging have you done? I'd start by looking in the browser's Network console... inspect the AJAX request and check what data its sending? FYI, you have no useful
<option>
elements in your <select>
so I'm not sure what sort of value you expect– Phil
Nov 20 at 5:41
@Phil in my
<option>
I append the dropdown using javascript , then what I am expecting is when I select one of the value in my <select>
it will appear in my DataTable– koroku
Nov 20 at 5:45
@Phil in my
<option>
I append the dropdown using javascript , then what I am expecting is when I select one of the value in my <select>
it will appear in my DataTable– koroku
Nov 20 at 5:45
So, about that Network console...
– Phil
Nov 20 at 5:46
So, about that Network console...
– Phil
Nov 20 at 5:46
1
1
@Phil ohh.. sorry my bad, my error only is the url of the API i used in dataTable for phalcon. I just review the documentation of that API then I get to that. that's it.
– koroku
Nov 22 at 1:28
@Phil ohh.. sorry my bad, my error only is the url of the API i used in dataTable for phalcon. I just review the documentation of that API then I get to that. that's it.
– koroku
Nov 22 at 1:28
|
show 10 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386728%2fphalcon-php-select-option-value-post-in-table-using-datatable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@Phil yeah sure, my bad.
– koroku
Nov 20 at 5:39
What debugging have you done? I'd start by looking in the browser's Network console... inspect the AJAX request and check what data its sending? FYI, you have no useful
<option>
elements in your<select>
so I'm not sure what sort of value you expect– Phil
Nov 20 at 5:41
@Phil in my
<option>
I append the dropdown using javascript , then what I am expecting is when I select one of the value in my<select>
it will appear in my DataTable– koroku
Nov 20 at 5:45
So, about that Network console...
– Phil
Nov 20 at 5:46
1
@Phil ohh.. sorry my bad, my error only is the url of the API i used in dataTable for phalcon. I just review the documentation of that API then I get to that. that's it.
– koroku
Nov 22 at 1:28