Hi
In my HTML table i want to get the checked value for each row in my table, but it keeps returning false even know that i am selecting it
What I have tried:
$(document)
.ready(function () {
var myUrl = $("#myUrl").val();
var arrayDetails = new Array();
var row = 1;
function NewEntry(area, process, value1, value2, value3, comment) {
this.Area = area;
this.Process = process;
this.Value1 = value1;
this.Value2 = value2;
this.Value3 = value3;
this.Comment = comment;
}
$('#ProList').on('change', function () {
var selectedValue = $('#ProList').val();
$.ajax({
type: "GET",
url: myUrl1,
contentType: "application/json; charset=utf-8",
datatype: JSON,
data: { 'proList': selectedValue },
success: function (result) {
$("#mainData").empty();
$.each(JSON.parse(result), function (i, item) {
var row = i + 1;
$("#mainData").append(
"" +
"" + item.Process + "" +
"" + item.Checks + "" +
"" +
"<div class="btn-group" data-toggle="buttons" "="" +="">" +
"<label class="btn btn-success" "="" +="">" +
"<input type="radio" name="options1" id="green_" + row + "" "="" +="">" +
"<span class="glyphicon glyphicon-ok" "="" +=""></span>" +
"</label>" +
"<label class="btn btn-warning" "="" +="">" +
"<input type="radio" name="options2" id="yellow_" + row + "" "="" +="">" +
"<span class="glyphicon glyphicon-ok" "="" +=""></span>" +
"</label>" +
"<label class="btn btn-danger" "="" +="">" +
"<input type="radio" name="options3" id="red_" + row + "" "="" +="">" +
"<span class="glyphicon glyphicon-ok" "="" +=""></span>" +
"</label>" +
"" +
"<textarea id=" + " '"="" +="" "comments_"="" row="" "'"="" "type="text" placeholder="" class="form-control input-md"></td>" +
"</tr>");
});
},
error: function () {
}
});
});
<pre> $("#subButton").click(function () {
var rowCount = $('#mainData >tr').length;
for (var i = 1; i <= rowCount; i++)
{
var areaEntered = document.getElementById("process_" + i).innerText;
var processEntered = document.getElementById("checks_" + i).innerText;
var valueEntered1 = document.getElementById("green_" + i).checked;
var valueEntered2 = document.getElementById("yellow_" + i).checked;
var valueEntered3 = document.getElementById("red_" + i).checked;
var commentEntered = document.getElementById("comments_" + i).value;
var entry = new NewEntry(areaEntered, processEntered, valueEntered1, valueEntered2, valueEntered3, commentEntered);
arrayDetails.push(entry);
}
sendToController();
});
function sendToController() {
$.ajax({
type: "POST",
url: myUrl,
contentType: "application/json; charset=utf-8",
datatype: JSON,
data: JSON.stringify({ methodParam: arrayDetails }),
success: function () {
alert(" Click Ok to return");
},
error: function () {
alert(test);
}
});
}
});</textarea></div>