function getOrders(res) {

    fetch("https://fb.magnolify.com/shopify.php?r="+Math.random().toString(16).slice(2))
		.then(response => response.text())
		.then(result => makeSelect(result))
		.catch(error => console.log('error', error));

    //console.log(res);
    //document.getElementById("msg").innerHTML = JSON.stringify(res, null, 2)
    document.getElementById("tracking").value = "";

  }
function makeSelect(res){
  //console.log('res: '+res);
    //var res = '{"orders":[{"id":5443742040277,"fulfillment_status":null,"name":"#BC1063","phone":null,"tags":"Online Store, purple-albino","fulfillments":[],"shipping_address":{"first_name":"Kelly","address1":"421 2nd Street","phone":"+16626609084","city":"Belmont","zip":"38827","province":"Mississippi","country":"United States","last_name":"Ortner","address2":null,"company":null,"latitude":34.5138014,"longitude":-88.21334449999999,"name":"Kelly Ortner","country_code":"US","province_code":"MS"}},{"id":5440307724501,"fulfillment_status":null,"name":"#BC1062","phone":null,"tags":"lavender-albino-1, Online Store","fulfillments":[],"shipping_address":{"first_name":"Dahlia","address1":"18803 Cerise Avenue","phone":"3109720632","city":"Torrance","zip":"90504","province":"California","country":"United States","last_name":"Bakshi","address2":null,"company":null,"latitude":33.8604188,"longitude":-118.3336157,"name":"Dahlia Bakshi","country_code":"US","province_code":"CA"}},{"id":5438563090645,"fulfillment_status":null,"name":"#BC1061","phone":null,"tags":"green-anaconda, Online Store","fulfillments":[],"shipping_address":{"first_name":"Luis","address1":"242 Best Street","phone":"+19394891449","city":"Bedford","zip":"44146","province":"Ohio","country":"United States","last_name":"Calderon Vazquez","address2":null,"company":null,"latitude":41.3735652,"longitude":-81.5185187,"name":"Luis Calderon Vazquez","country_code":"US","province_code":"OH"}},{"id":5436694659285,"fulfillment_status":null,"name":"#BC1060","phone":null,"tags":"Facebook \u0026 Instagram, red-pastel","fulfillments":[],"shipping_address":{"first_name":"Jessica","address1":"3835 County Road 127","phone":null,"city":"Fort Payne","zip":"35967","province":"Alabama","country":"United States","last_name":"Berry","address2":"","company":"","latitude":34.3599576,"longitude":-85.70541229999999,"name":"Jessica Berry","country_code":"US","province_code":"AL"}},{"id":5428784431317,"fulfillment_status":null,"name":"#BC1049","phone":null,"tags":"Online Store","fulfillments":[],"shipping_address":{"first_name":"Larry","address1":"9581 Summerfield St","phone":"(469) 585-4676","city":"Spring Valley","zip":"91977","province":"California","country":"United States","last_name":"La Point","address2":null,"company":null,"latitude":32.7443483,"longitude":-116.9910773,"name":"Larry La Point","country_code":"US","province_code":"CA"}}]}';
    //var json = JSON.parse(res);
    var json = JSON.parse(res); 
    var temp = JSON.stringify(json);
    temp = temp.replace(/\"\"/g, "\"\"");
    json = JSON.parse(temp);
    console.log(json)

    var select = document.getElementById("Select");
    document.getElementById("tracking").value = "";
    //select.remove();
    for(i = select.options.length - 1 ; i >= 0 ; i--)
    {
      console.log('remove: '+select.options[i].value);
      select.remove(i);
    }
  for (var i = 0; i < json.orders.length; i++) {
    
    
    var option = document.createElement("option");
    option.value = JSON.stringify(json.orders[i]);
    option.text = '('+json.orders[i].name+') '+json.orders[i].shipping_address.first_name + ' ' + json.orders[i].shipping_address.last_name;
    select.add(option);
    

  } 
  setTracking(); 
}
getOrders(1);
    //https://fb.magnolify.com/shopify.php

//https://bobclarkreptiles.myshopify.com/admin/api/2023-10/orders.json?fulfillment_status=unshipped&fields=id,name,fulfillment_status,fulfillments,phone,tags,shipping_address