I'm building a web form that populates dynamically from a stored procedure. It is a table with a dropdown list and a text box and one label. I can successfully grab the data from the dropdown and the text box, but I cannot grab the data from the label. Here is the code that populates the data section of the table.
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'><select name='select_" + count + "'><option value='Pending'>Pending</option><option value='Approve'>Approve</option><option value='Deny'>Deny</option></select></td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'><input type='text' name='comments_" + count + "' /></td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + locationNum + "</td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + shipToNum + "</td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + address + "</td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + city + "</td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + state + "</td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + zip + "</td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + soldToName + "</td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + exemptionDescription + "</td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'><label for='select_" + count + "' name='label_" + count + "'>" + exemptionRequestDetailID + "<label></td>");
sb.Append("<td style='border-top: 1px solid black; border-left: 1px solid black;'>" + reason + "</td>");
Here is the code that grabs the needed data from the table in the aspx page and sends it to the codebehind for manipulation.
function SendForm() {
var count = 0;
var elLength = form1.elements.length;
for (i = 0; i < elLength; i++) {
var type = form1.elements[i].type;
alert(type);
if ((type == "select-one") && (form1.elements[i].value != "Pending")) {
count++
}
}
var data = new Array(count);
var text = new Array(count);
var exempID = new Array(count);
for (i = 0; i < elLength; i++) {
var type = form1.elements[i].type;
if ((type == "select-one") && (form1.elements[i].value != "Pending")) {
data[i] = form1.elements[i].value;
}
if ((type == "text") && ((form1.elements[i-1].value == "Approve") || (form1.elements[i-1].value == "Deny"))) {
text[i] = form1.elements[i].value;
}
if ((type == "label") && ((form1.elements[i-2].value == "Approve") || (form1.elements[i-2].value == "Deny"))) {
alert(form1.elements[i].value);
}
}
PageMethods.SendForm(data, text, OnSucceeded, OnFailed);
}
I have alerts set up to check if it is grabbing the label values, but it is showing nothing at all for the label. Any help would be appreciated.