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.










share|improve this question
























  • @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















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.










share|improve this question
























  • @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













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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • @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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen