Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  1. $("#select-choice").on('change', function(event) {
  2. //$('#select-choice-location option[value!="Select Location"]').remove();
  3. var catg = this.value;
  4. var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
  5. db.transaction(function (tx) {
  6. tx.executeSql("select Location from Locationlog WHERE Category = '"+catg+"';", [], function (tx, res) {
  7. for (var i = 0; i < res.rows.length; i++) {
  8. var opt = '<option value="';
  9. opt += res.rows.item(i).Location;
  10. opt += '">';
  11. opt += res.rows.item(i).Location;
  12. opt += '</option>';
  13. $("#select-choice-location").append(opt);
  14. }
  15. $("#select-choice-location").listview('refresh');
  16. });
  17. });
  18. });
  19.  
  20. <select name="select-choice" id="select-choice">
  21. <option value="Select Category">Select Category</select>
  22. </select>
  23. <select name="select-choice-location" id="select-choice-location">
  24. <option value="Select Location">Select Location</select>
  25. </select>
  26.  
  27. $("#select-choice-location").empty().append(opt)
  28.  
  29. $("#select-choice").on('change', function(event) {
  30. $("#select-choice-location").empty(); // Here you clear
  31. var catg = this.value;
  32. var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
  33. db.transaction(function (tx) {
  34. tx.executeSql("select Location from Locationlog WHERE Category = '"+catg+"';", [], function (tx, res) {
  35. var opt = '<option value="">Select</option>';
  36. for (var i = 0; i < res.rows.length; i++) {
  37. opt += '<option value="';
  38. opt += res.rows.item(i).Location;
  39. opt += '">';
  40. opt += res.rows.item(i).Location;
  41. opt += '</option>';
  42.  
  43. $("#select-choice-location").append(opt);
  44. }
  45. $("#select-choice-location").listview('refresh');
  46. });
  47. });
  48. });
  49.  
  50. $("#select-choice").on('change', function (event) {
  51. var catg = this.value;
  52. var db = window.sqlitePlugin.openDatabase({
  53. name: "MYDB"
  54. });
  55. db.transaction(function (tx) {
  56. tx.executeSql("select Location from Locationlog WHERE Category = '" + catg + "';", [], function (tx, res) {
  57. var opt = '<option value="">Select</option>';
  58. for (var i = 0; i < res.rows.length; i++) {
  59. opt += '<option value="';
  60. opt += res.rows.item(i).Location;
  61. opt += '">';
  62. opt += res.rows.item(i).Location;
  63. opt += '</option>';
  64. }
  65. $("#select-choice-location").empty().append(opt);
  66. $("#select-choice-location").listview('refresh');
  67. });
  68. });
  69. });
  70.  
  71. $("#select-choice").on('change', function (event) {
  72. $("#select-choice-location").empty(); // clear
  73. var catg = this.value;
  74. var db = window.sqlitePlugin.openDatabase({
  75. name: "MYDB"
  76. });
  77. db.transaction(function (tx) {
  78. tx.executeSql("select Location from Locationlog WHERE Category = '" + catg + "';", [], function (tx, res) {
  79. var opt = '<option value="">Select</option>';
  80. for (var i = 0; i < res.rows.length; i++) {
  81. opt += '<option value="';
  82. opt += res.rows.item(i).Location;
  83. opt += '">';
  84. opt += res.rows.item(i).Location;
  85. opt += '</option>';
  86.  
  87. $("#select-choice-location").append(opt);
  88. }
  89. $('select').selectmenu('refresh', true);
  90. });
  91. });
  92. });
  93.  
  94. var options = {
  95. Select1: ["A", "B", "C"],
  96. Select2: ["D", "E", "F"],
  97. Select3: ["G", "G", "I"]
  98. };
  99.  
  100. $(function () {
  101. $('#firstSelect').change(function () {
  102. var x = $('#firstSelect :selected').val();
  103. $('#secondSelect').html("");
  104. for (index in options[x]) {
  105. $('#secondSelect').append('<option value="' + options[x][index] + '">' + options[x][index] + '</option>')
  106. };
  107. });
  108. });
  109.  
  110. $("#select-choice").on('change', function(event) {
  111. //$('#select-choice-location option[value!="Select Location"]').remove();
  112. var catg = this.value;
  113. var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
  114. db.transaction(function (tx) {
  115. tx.executeSql("select Location from Locationlog WHERE Category = '"+catg+"';", [], function (tx, res) {
  116. for (var i = 0; i < res.rows.length; i++) {
  117. var opt = '<option value="';
  118. opt += res.rows.item(i).Location;
  119. opt += '">';
  120. opt += res.rows.item(i).Location;
  121. opt += '</option>';
  122. $("#select-choice-location").empty();
  123. $("#select-choice-location").append(opt);
  124. }
  125. $("#select-choice-location").listview('refresh');
  126. });
  127. });
  128. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement