How to pass textbox id as a parameter to the function in javascrip
<asp:TextBox ID="txtRatingA" runat="server" onblur="ShowRatingDetails(this,1)">0</asp:TextBox>
<asp:Label ID="lbltxtRatingDetailsA" runat="server"></asp:Label>
<asp:TextBox ID="txtRatingB" runat="server" onblur="ShowRatingDetails(this,2)">0</asp:TextBox>
<asp:Label ID="lbltxtRatingDetailsB" runat="server"></asp:Label>
<script type="text/javascript">
function ShowRatingDetails(SourceID, Type) {
var inputval = SourceID.value;
var resultval = "";
if (inputval == 1)
resultval = "Unacceptable – Inaccurate";
else if (inputval == 2)
resultval = "Unacceptable (Borderline)";
var TargetID = "";
if (Type == 1)
TargetID = '<%=lbltxtRatingDetailsA.ClientID %>';
else if (Type == 2)
TargetID = '<%=lbltxtRatingDetailsB.ClientID %>';
if (TargetID != "")
document.getElementById(TargetID).innerHTML = resultval;
}
</script>
<asp:Label ID="lbltxtRatingDetailsA" runat="server"></asp:Label>
<asp:TextBox ID="txtRatingB" runat="server" onblur="ShowRatingDetails(this,2)">0</asp:TextBox>
<asp:Label ID="lbltxtRatingDetailsB" runat="server"></asp:Label>
<script type="text/javascript">
function ShowRatingDetails(SourceID, Type) {
var inputval = SourceID.value;
var resultval = "";
if (inputval == 1)
resultval = "Unacceptable – Inaccurate";
else if (inputval == 2)
resultval = "Unacceptable (Borderline)";
var TargetID = "";
if (Type == 1)
TargetID = '<%=lbltxtRatingDetailsA.ClientID %>';
else if (Type == 2)
TargetID = '<%=lbltxtRatingDetailsB.ClientID %>';
if (TargetID != "")
document.getElementById(TargetID).innerHTML = resultval;
}
</script>
Comments
Post a Comment