Reputation: 391
I am working on a website that involves cascading combo boxes that I am attempting to sidestep on the client side. Right now I have two combo boxes, defined in HTML and populated using asp:
<asp:ObjectDataSource ID="odsSalesReps" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAllRepNumbers" TypeName="boReps">
</asp:ObjectDataSource>
This first box is easily populated with all names of sales representatives. The second box will contain the companies that the selected sales rep represents. Therefore, this SQL query does have an input parameter, which is the desired rep name. Currently, it is populated like this:
<asp:ObjectDataSource ID="odsMFGFromAgency" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetMFGForRepNumber" TypeName="boReps">
<SelectParameters>
<asp:QueryStringParameter Name="repNum" QueryStringField="REP_NUMBER" Type="Decimal" />
</SelectParameters>
</asp:ObjectDataSource>
I have written a small Javascript function that retrieves the selected sales representative name, as seen here:
function GetSelectedRep(sender) {
var comboFromRepValue = sender.ComboBox.SelectedItem.Text;
}
My question: Can I just use the return value (once I alter the JS function to have one) to be the input parameter for populating the second combobox? I could keep this all on the client side, which would be very nice. I would need to wait for the initial selection to repopulate (or something) which would be another challenge, but I can resolve that later. I would like to stay out of the codebehind if possible.
Upvotes: 1
Views: 288