Hi All,

Im in the process of creating a task logging system for where i work, and at the moment im in the process creating a ajaz function where it will return a list of all users depending on what team the user has selected from the 1 dropdownlist but unfortunatly im having a bit of trouble calling the javascript function and passing in the selected value from the TeamsDropDownList

Heres my HTML

<div class="RightBoxPopUpBussinessAnalyst">
                <asp:DropDownList ID="cmbBAAllocatedTeam" runat="server" AutoPostBack="true" onchange="javascript:GetTeamUsersByTeamID('MainDisplayContentChange_DropDownList5');">
                    <asp:ListItem>Business Analyst</asp:ListItem>
                    <asp:ListItem>Lansa Davelopment</asp:ListItem>
                    <asp:ListItem Value="214">.Net</asp:ListItem>
                </asp:DropDownList>
            </div>

As you can see the last listitem has a value of 214 this is the one im using for testing and you can also see the onchange passing in the ID of the dropdown is that correct?

Javascript function

function GetTeamUsersByTeamID(field) 
{
    getUserTeamProperties(document.getElementById(field).value);
}

im passing in the field name, then using document.getElementById to get the value of the field i have passed in, but i keep getting this error "value is not defined" thats within the javascript file, is there a simpler way of doing this such of thing, the getUserTeamProperties is the start of the ajax but it falls over after entering the GetTeamUserByTeamID,

And just for your information im sure your aware the 'MainDisplayContentChange_DropDownList5' is the name of the dropdownlist when the ASP.NET Application is running well according to the source page it is.
Thanks in advance

Recommended Answers

All 4 Replies

Hi

Hi can you help me achieve the above?

You should have to append an attribute is code-behind.

if(!IsPostBack)
        {
          cmbBAAllocatedTeam.Attributes.Add("onchange", "GetTeamUsersByTeamID('" + DropDownList2.ClientID + "')");
        }

Can i no just reference the value within javascript im trying this at the moment but it keeps saying object expected

function GetTeamUsersByTeamID(field) 
{
    var e = document.getElementById('field'); // select element
    var strUser = e.options[e.selectedIndex].value;
    alert(strUser);
}

as you can see im passing in the field name from the HTML above
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.