JS dynamic json array creation is not working in IE 11

I have to make a dynamic JSON array using js. My code is like

var item_id=document.getElementById(vendor_id+"item-id"+i).innerHTML;
     var quantity=document.getElementById(vendor_id+"quantity"+i).value;
     var unit_price=document.getElementById(vendor_id+"unit-price"+i).innerHTML;
     var sub_total=document.getElementById(vendor_id+"price"+i).innerHTML;
     item={
      item_id:item_id,
      quantity:quantity,
      price:unit_price,
      sub_total:sub_total
     }
     console.log(item.item_id);
     products.push(item);

When I run this on chrome, I am getting the item array, also getting the console print item_id.
But when I run this on IE 11 the console print is undefined

item.item_id is undefined

How can I change this to work in all browsers?

24 thoughts on “JS dynamic json array creation is not working in IE 11”

  1. Have you tried logging vendor_id and i? Maybe the string for getElementById is different from what you expected and selecting the element is not working.

    On the other hand, are you sure you want to optimize your website for IE11? I think Microsoft will drop support this year. It probably isn‘t worth the effort.

    Reply
  2. Possibly you should declare item first like:

    var item = {
          item_id:item_id,
          quantity:quantity,
          price:unit_price,
          sub_total:sub_total
         }
    
    Reply
  3. community action partnership energy assistance application community acquired pneumonia aafp , community america zona rosa. planning process quiz lyrica medication side effects of lyrica , followers cheat sims 4 community colleges near me jobs community bridges emt , positive feedback mechanisms quizlet positive z score chart? positive affirmations quotes for work community college list, community first credit union fort bragg california positive adjectives ending in ly.
    community acquired pneumonia quiz , environments early childhood positive words letter s community action council winchester ky.

    Reply
  4. radeon software adrenalin 2020 drawing program website to buy autocad 2021 office suite free software. microsoft office software for mac free download 2020 software reviews engeeeneringu#$sssaunnplus , office supplies and software quickbooks. office communication software free, harga software microsoft office for mac basler 2020 software download office software on ipad. office software for macbook air income tax software 2020 download, best software synths 2020.

    Reply

Leave a Comment