Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @helper DynamicDropDowns() {
- <script type="text/javascript">
- function listChanged($list, $target, url) {
- var listId = $list.val();
- if (listId == "") { // User selected first option, so clear and disable the list
- $target.empty();
- enableList($target, false);
- return;
- }
- $.getJSON(url, { id: listId }, function (data) {
- $target.empty(); // Clear the list
- $.each(data, function (idx, item) { // Add the data
- $target.append($("<option/>",
- {
- value: item.Value,
- text: item.Text
- }));
- });
- enableList($target, true); // Enable the list
- });
- }
- function enableList($list, enabled) {
- $list.attr("disabled", enabled ? null : "disabled");
- }
- </script>
- }
Add Comment
Please, Sign In to add comment