disabling dropdownlist inside a gridview based on value selected on another dropdownlist inside the gridview from javascript or jquery
Posted
by
Joy
on Stack Overflow
See other posts from Stack Overflow
or by Joy
Published on 2011-01-11T08:35:50Z
Indexed on
2011/01/11
8:53 UTC
Read the original article
Hit count: 250
what i m trying is i hav two dropdownlists inside the gridview... namely say ddonsiteoffsite and ddhours... now what i want is if the selectedtext of ddonsiteoffsite is "onsite" the ddhours should b disabled... i tried the code snippet but ... its not disabling the ddhours... can someone help me please..
<asp:TemplateColumn HeaderText=" OnSite/OffSite" >
<ItemTemplate>
<asp:DropDownList ID="ddOnsiteOffside" runat="server" onchange="ToggleOnOff(this)"><asp:ListItem Text = "Offsite" Value="Offsite"></asp:ListItem>
<asp:ListItem Text = "Onsite" Value="Onsite"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList ID="ddhours" runat="server">
<asp:ListItem Text = "1" Value="1" ></asp:ListItem>
<asp:ListItem Text = "2" Value="2" ></asp:ListItem>
<asp:ListItem Text = "3" Value="3" ></asp:ListItem>
<asp:ListItem Text = "4" Value="4" ></asp:ListItem>
<asp:ListItem Text = "5" Value="5" ></asp:ListItem>
<asp:ListItem Text = "6" Value="6" ></asp:ListItem>
<asp:ListItem Text = "7" Value="7" ></asp:ListItem>
<asp:ListItem Text = "8" Value="8" ></asp:ListItem>
<asp:ListItem Text = "9" Value="9" ></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
and the corresponding javascript i am using is :
enter code here
function ToggleOnOff(ddonoff)
{
var row = chk.parentNode.parentNode;
if(ddonoff.value=="Onsite")
{
row.getElementsByTagName("ddhours")[0].disabled = true;
}
else
row.getElementsByTagName("ddhours")[0].disabled = false;
}
can someone help to achieve this ?? using javascript or jquery ? i m not understanding where i went wrong ...
© Stack Overflow or respective owner