I have two questiosn.
1)
I have a list box which gets populated depending on what I select in my 1st drop down.
The data is retrieved using jQuery.get.
The code for generating the list looks like this:
(...)
foreach (DataRow row in dt.Rows)
{
strList.Append("<option value='" + row["id"] + "'>" + row["enhetsnavn"] + "</option>");
}
I append the result to my drop down list with the following code:
var schoolsList = $("#schoolSelect");
jQuery.get(
site + "jQueryFunctions.ashx",
{
county: county, schoolType: schoolType, instance: 'getSchoolsByCounty' },
function(data) {
schoolsList.append(data);
}
);
This works great the first time. The problem is that if I select something new from the 1st ddl, it gets added to the 2nd list thus not replacing existing items.
(the list just keeps getting longer and longer).
How do I replace the list items with the new ones?
2)
If I remember correctly, populating the 2nd drop down list using jQuery will not bind the data. And if it's not bound, I'm not able to retrieve value / data using jQuery.
I think I had to use jQuery.live or something?