I have 2 select or dropdown to my datagrid. Since Im doing this and im using getElementByTagName. The javascript is not functioning correctly since I have 2 select tag names If could use getElementID or getElementName for the select/dropdown I think I could get it to work.
Does anyone know how to do this
Thanks
Code:function OnChange(down) { var flag = true; var dropdowns = new Array(); //Create array to hold all the dropdown lists. // var credit = new Arry(); var gridview = document.getElementById('<%=myDataGrid.ClientID %>'); //GridView1 is the id of ur gridview. dropdowns = gridview.getElementsByTagName('select'); //Get all dropdown lists contained in GridView1. for (var i = 0; i < dropdowns.length; i++) { if (dropdowns.item(i).value == '2') //If dropdown has no selected value { // down.parentElement.nextSibling.children[9].style.display = dis; var txtshow = new Array(); txtshow = gridview.getElementsByTagName('input'); txtshow.item(i).style.display = 'block'; flag = false; } else { var txtshow = new Array(); txtshow = gridview.getElementsByTagName('input'); txtshow.item(i).style.display = 'none'; } if (dropdowns.item(i).value == '1') { var txtDrop = new Array(); txtDrop = gridview.getElementsByTagName('label'); txtDrop.item(i).style.display = 'block'; } else { var txtDrop = new Array(); txtDrop = gridview.getElementsByTagName('label'); txtDrop.item(i).style.display = 'none'; } if (dropdowns.item(i).value == '3') -ERROR STARTS HERE { var txtOption = new Array(); txtOption = gridview.getElementsByTagName('select'); txtOption.item(i).style.display = 'block'; } else { var txtOption = new Array(); txtOption = gridview.getElementsByTagName('select'); txtOption.item(i).style.display = 'none'; } } return flag; } //--> </script> <asp:DropDownList ID="DropDownList1" runat="server" onchange="javascript:OnChange(this);" Enabled="True"> <asp:ListItem Value ="0" >Select an Action</asp:ListItem> <asp:ListItem Value ="1" >Drop</asp:ListItem> <asp:ListItem Value ="2" >Change</asp:ListItem> <asp:ListItem Value ="3" >Option</asp:ListItem> </asp:DropDownList> </ItemTemplate></asp:TemplateColumn> This is in another column in the datagrid. This is the dropdown I want to toggle display. <asp:TemplateColumn HeaderText="Option" Visible="true"> <ItemTemplate> <select id="Select1" name="option"> <option>U</option> <option>R</option> <option>P</option> <option>S</option> </select> </ItemTemplate> </asp:TemplateColumn>


Reply With Quote
Bookmarks