Please help I wanted to use this code to validate marks enter and also, to tick the value enter using javascript but I have successfully not been pleased help.
I wanted upon entering a score the checkbox is ticked using this very code.
function GetSelectedRow(UserLink) {
var row = UserLink.parentNode.parentNode;
var rowIndex = row.rowIndex - 1;
var userId = row.cells[0].innerHTML;
var lable = row.getElementsByTagName("input")[2].value;
if (lable == null || lable == "") {
row.getElementsByTagName("input")[8].value = "d";
return true;
}
else
row.getElementsByTagName("input")[8].value = "";
if (lable >= 0 && lable <= 100) {
return true;
}
else {
alert("Must be between 1 and 100");
return false;
}
}
I am getting error at line 4
var userId = row.cells[0].innerHTML;
It flags an error
Unable to get property '0' of undefined or a null reference
<asp:GridView ID="GvStudentMarks" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvStudentMarks_RowDataBound">
<columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="chkAll" runat="server" AutoPostBack="true" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Eng">
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblEng" runat="server" Text='<%# Eval("Eng") %>' Visible="False"></asp:Label>
<asp:TextBox ID="TxtEng" runat="server" OnTextChanged="txtEng_TextChanged" Text='<%# Eval("Eng") %>' onkeyup="enter(this)" AutoPostBack="True" Height="16px" Width="58px" onchange="return GetSelectedRow(this)"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server" BackColor="#FF99FF" ControlToValidate="TxtEng" Display="Dynamic" ErrorMessage="Invalid" MaximumValue="100" MinimumValue="0" SetFocusOnError="True" Type="Double"></asp:RangeValidator>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Maths">
<ItemTemplate>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="lblMaths" runat="server" Text='<%# Eval("Maths") %>' Visible="False"></asp:Label>
<asp:TextBox ID="TxtMaths" runat="server" OnTextChanged="txtMaths_TextChanged" Text='<%# Eval("Maths") %>' onkeyup="enter(this)" AutoPostBack="True" Width="48px" onchange="return GetSelectedRow(this)"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator2" runat="server" BackColor="#FF99FF" ControlToValidate="TxtMaths" Display="Dynamic" ErrorMessage="Invalid" MaximumValue="100" MinimumValue="0" SetFocusOnError="True" Type="Double"></asp:RangeValidator>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TotalMarks">
<ItemTemplate>
<asp:Label ID="lblTotalMarks" runat="server" Text='<%# Eval("avgs") %>' Visible="False"></asp:Label>
<asp:TextBox ID="txtTotalmarks" runat="server" Text='<%# Eval("Avgs") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Average">
<ItemTemplate>
<asp:TextBox ID="txtAverage" runat="server" Text='<%# Eval("Avgs2") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</columns>
</asp:GridView>