I have a auto generated table and with in that there is an input field. how can I get the value?
I have a auto generated table and with in that there is an input field. how can I get the value?
malhamoud
Posts: 11Questions: 2Answers: 0
I'm trying to get the value of below input tag as you can see in the code below I'm getting the data from the product table and send the selected items with the quantity to another table, I manage to get selected Item but when I want to get the quantity I could not get the input field value
$(document).ready(function () {
var q1 = 0
var table = $("#products").DataTable({
"processing": true,
"filter": false,
ajax: {
url: "/api/products",
dataSrc: "",
dataType: "json",
},
"columnDefs":
[{
"targets": [0],
"visible": true,
"searchable": false
}],
columns:
{
data: "productId", render: function (data) {
return element = "<input type='text' name='qty' id='" + data + "' class='form-control' placeholder='' aria-label='' aria-describedby='basic-addon1'>";
}
}
using the function below:
`function addToSlectedItemsData(ProductId) {
if (confirm("Are you sure you want to add ...?"))
{
var qty = document.getElementById(ProductId).val;
console.log(ProductId + qty);
}
else
{
return false;
}
}
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
This thread should help, it's asking the same thing.
Cheers,
Colin