JavaScript javascript foreach select loop with selected value javascript foreach select options,javascript foreach select

I've written the following code that generates a select list. However, the part where it's supposed to check if this.id equals the same as the existing_code and put the selected value in doesnt seem to work.

any ideas what is wrong?

function showHide(layer, existing_code) {

jQuery.ajax({ url: 'getdata.php', dataType: 'json', cache: 'false', success: function(data) {

    var codes = codes;
    var selectcode = '';

    selectcode += '<select name="codes">';  
        jQuery.each(codes, function() {
            selectcode += '<option value="' + this.id + '"';
                if (this.id == existing_code) {
                    selectcode += ' selected';
                }
            selectcode += '>' + this.code + '</option>';
        });
    selectcode += '</select>';  

    jQuery('.'+layer).html(selectcode);

}});

}
Answer:1

In VueJS, I have seen different ways of accessing parent properties from a component. Say I want to use the parent property items in my component. First way The component has a props value bound to ...

In VueJS, I have seen different ways of accessing parent properties from a component. Say I want to use the parent property items in my component. First way The component has a props value bound to ...

My application architecture is simple Front end using ionic-angularjs with backend nodejs interfacing with mongodb. My application will require ability to submit data related to reimbursement (say few ...

My application architecture is simple Front end using ionic-angularjs with backend nodejs interfacing with mongodb. My application will require ability to submit data related to reimbursement (say few ...

So I trying to Mock a date in my test, this is what I did : const mockDate = new Date('2018-01-01'); const backupDate = Date; beforeEach(() => { (global.Date as any) = jest.fn(() => ...

So I trying to Mock a date in my test, this is what I did : const mockDate = new Date('2018-01-01'); const backupDate = Date; beforeEach(() => { (global.Date as any) = jest.fn(() => ...

  1. mock date jest
  2. mock new date jest
  3. mock date.now jest
  4. mock date constructor jest
  5. mock current date jest
  6. mock date object jest
  7. mock global date jest
  8. moment mock date jest
  9. mock date gettime jest
  10. mock date function jest
  11. mock date javascript jest
  12. jest mock date timezone
  13. jest mock date toisostring
  14. jest mock date typescript
  15. jest mock date time
  16. jest mock date-fns
  17. jest mock date constructor typescript
  18. jest mock date class
  19. jest mock date tolocalestring
  20. jest mock date prototype

I have a string composed by several fields. Two of which will always vary in length. I could simply use substring if all fields have fixed lengths. Sample: ...

I have a string composed by several fields. Two of which will always vary in length. I could simply use substring if all fields have fixed lengths. Sample: ...

  1. javascript contains substring
  2. javascript check substring
  3. javascript check substring in string
  4. javascript contains substring ignore case
  5. javascript contains substring in string
  6. javascript check substring case insensitive
  7. javascript check substring exists
  8. javascript check substring exists in string
  9. javascript contains substring in array
  10. javascript check substring in array
  11. javascript contains substring function
  12. javascript contains substring es6
  13. js contains substring
  14. js check substring
  15. js check substring in string
  16. javascript matching substrings
  17. js substring matching