Use different data sources to populate a table based on selection from a list

can I use the below code as the javascript to dynamically select a data source:

switch (FilteredBy.selectedIndex) {
case 2:
Q06();
break;
case 6:
Q07();
break;
default:
// Default case logic (if needed)
}

You can't set the data of table directly. The work around is set a variable, and set it as datasource of table, then you can set the default value to the selectedItem of list.