SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dropdown display in datagrid

    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>
    Last edited by ScallioXTX; Aug 9, 2012 at 00:19.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •