Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#select-choice").on('change', function(event) {
- //$('#select-choice-location option[value!="Select Location"]').remove();
- var catg = this.value;
- var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
- db.transaction(function (tx) {
- tx.executeSql("select Location from Locationlog WHERE Category = '"+catg+"';", [], function (tx, res) {
- for (var i = 0; i < res.rows.length; i++) {
- var opt = '<option value="';
- opt += res.rows.item(i).Location;
- opt += '">';
- opt += res.rows.item(i).Location;
- opt += '</option>';
- $("#select-choice-location").append(opt);
- }
- $("#select-choice-location").listview('refresh');
- });
- });
- });
- <select name="select-choice" id="select-choice">
- <option value="Select Category">Select Category</select>
- </select>
- <select name="select-choice-location" id="select-choice-location">
- <option value="Select Location">Select Location</select>
- </select>
- $("#select-choice-location").empty().append(opt)
- $("#select-choice").on('change', function(event) {
- $("#select-choice-location").empty(); // Here you clear
- var catg = this.value;
- var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
- db.transaction(function (tx) {
- tx.executeSql("select Location from Locationlog WHERE Category = '"+catg+"';", [], function (tx, res) {
- var opt = '<option value="">Select</option>';
- for (var i = 0; i < res.rows.length; i++) {
- opt += '<option value="';
- opt += res.rows.item(i).Location;
- opt += '">';
- opt += res.rows.item(i).Location;
- opt += '</option>';
- $("#select-choice-location").append(opt);
- }
- $("#select-choice-location").listview('refresh');
- });
- });
- });
- $("#select-choice").on('change', function (event) {
- var catg = this.value;
- var db = window.sqlitePlugin.openDatabase({
- name: "MYDB"
- });
- db.transaction(function (tx) {
- tx.executeSql("select Location from Locationlog WHERE Category = '" + catg + "';", [], function (tx, res) {
- var opt = '<option value="">Select</option>';
- for (var i = 0; i < res.rows.length; i++) {
- opt += '<option value="';
- opt += res.rows.item(i).Location;
- opt += '">';
- opt += res.rows.item(i).Location;
- opt += '</option>';
- }
- $("#select-choice-location").empty().append(opt);
- $("#select-choice-location").listview('refresh');
- });
- });
- });
- $("#select-choice").on('change', function (event) {
- $("#select-choice-location").empty(); // clear
- var catg = this.value;
- var db = window.sqlitePlugin.openDatabase({
- name: "MYDB"
- });
- db.transaction(function (tx) {
- tx.executeSql("select Location from Locationlog WHERE Category = '" + catg + "';", [], function (tx, res) {
- var opt = '<option value="">Select</option>';
- for (var i = 0; i < res.rows.length; i++) {
- opt += '<option value="';
- opt += res.rows.item(i).Location;
- opt += '">';
- opt += res.rows.item(i).Location;
- opt += '</option>';
- $("#select-choice-location").append(opt);
- }
- $('select').selectmenu('refresh', true);
- });
- });
- });
- var options = {
- Select1: ["A", "B", "C"],
- Select2: ["D", "E", "F"],
- Select3: ["G", "G", "I"]
- };
- $(function () {
- $('#firstSelect').change(function () {
- var x = $('#firstSelect :selected').val();
- $('#secondSelect').html("");
- for (index in options[x]) {
- $('#secondSelect').append('<option value="' + options[x][index] + '">' + options[x][index] + '</option>')
- };
- });
- });
- $("#select-choice").on('change', function(event) {
- //$('#select-choice-location option[value!="Select Location"]').remove();
- var catg = this.value;
- var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
- db.transaction(function (tx) {
- tx.executeSql("select Location from Locationlog WHERE Category = '"+catg+"';", [], function (tx, res) {
- for (var i = 0; i < res.rows.length; i++) {
- var opt = '<option value="';
- opt += res.rows.item(i).Location;
- opt += '">';
- opt += res.rows.item(i).Location;
- opt += '</option>';
- $("#select-choice-location").empty();
- $("#select-choice-location").append(opt);
- }
- $("#select-choice-location").listview('refresh');
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement