how to get last weekday for a given date

I am trying to get the last weekday for a given date in my google sheets for which I have written the below custom function. If it is a saturday or sunday then i want to get the last friday which I assume is a weekday (leaving out edge cases where friday could be a holiday as well)

This does not work and I get the below ERROR. Can you please let me know where I am going wrong?

“An error occurred in the script, but there is no error code: Error: Cannot return an invalid date.”
In my

In my google sheets I am trying to call it as below
enter image description here

function lastBusinessDay(passedDate) {
  mydate = new Date(passedDate);
  console.log('date recieved ' + mydate);
  if(mydate.getDay()==1)
    return new Date(today.getFullYear(), today.getMonth(), today.getDate() - 2);
  else if(mydate.getDay()==6)
    return new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1);
  else
    return mydate;  
  
}

React Stacknavigator with Sidebar

i have a StackNavigator but want to display a sidebar like with the drawer navigation. I am using react-navigation 5.X.
Since the problem with the drawer navigator is with different params in the url not reloading the page.

Is there a nice solution for this problem?

How to call a function in a server side node file from a client side file

I have a Node.js file that contains a function which writes to local files. I need to call this function from a client side JavaScript file. How can you do this?

I have seen questions about how to call server side functions on an HTML event, but not just strait from a client side script at any time.

Here is the script to write to the local file:

function writeCreateFile(filePath, newValue, callback) {
  checkIfFileExists(filePath, function(exists) {
    if(exists){
      fs.writeFileSync(path.join(__dirname, filePath), newValue, 'utf-8')
    } else {
      fs.appendFileSync(path.join(__dirname, filePath),newValue);
    }
    callback();
  })

}

function checkIfFileExists(filePath, callback) {
  fs.readFile(filePath, 'utf-8', function(err, data) {
   callback(err);
 });
}

Has anyone seen a weird JavaScript multiplication error like this? 9.4 * 3.6 = 0.03127079174983367?

I’m converting from meters/second to kilometers/hour. Very straighforward, right?

enter image description here

So, 9.4 * 3.6 = 33.84, right? Well, step forward with the debugger, and…

enter image description here

0.03127079174983367!?

This is happening using Node.js v14.16.0. I’m going to update my Node.js version and see if that helps, but this is very weird. I’m using TypeScript, so I suppose this could also be a transpilation error.

If I use conditions.windSpeed = conditions.windSpeed * 3.6 the problem goes away.

Trouble with IF statements in Javascript

So to explain, I’ve created code that asks the user for their MBTI code (results from 16personalities.com).
If the user types INTJ, for instance, a list of celebrities who share that same result will appear. I was a bit confused on how to write the code. It’s a small amount so far, but I feel like it should work.

Here is my javascript, which connects to an HTML file.

const INTJ = ["Friedrich Neitzsche", "Michelle Obama", "Elon Musk", "Christopher Nolan", "Vladimir Putin", "Arnold Schwarzenegger", "Colin Powell", "Samantha Power"]


let button = document.querySelector("findlist");
let input = document.querySelector("mtbicode");

if (input == "INTJ"){
    button.addEventListener("click", INTJfunc);
    console.log("yay");
}

function INTJfunc(){
    var x = document.querySelector("matchups").innerHTML;
    return(x = INTJ) 
}

Basically by code make variables for the button that gets pressed, and the user input. If the user’s input is “INTJ”, The button (when clicked) will trigger the INTJ func. I also added a console log to test it, but that doesn’t seem to appear in the html console.

The INTJfunc function grabs the space where the results get displayed, and should display the results.

For some reason none of this works! Nothing appears in the console, and no errors show up either.

React: Can we pass 2 forms from 2 different child components to a parent, and submit them with a button which is inside the parent component?

I am trying to somehow pass the data from 2 forms and 2 different components to the parent component and then somehow console.log all of this data with a button that is inside the parent component. Then I will simply send these data to a JSON file or a dummy database.

When I press the submit button of course nothing is triggered right now because I simply don’t know how to pass the function from the children to the parent. I have tried many ways, but I would appreciate it if you could show me a way to lift the state and combine the forms.
For the input, in order to pass refs, I have used React.forwardRef()

It would be easy to just have 1 big component with 1 form and then the button inside this component, but since it is a fun project, I want to learn how to implement this functionality in case I will use it in the future. You can find a screenshot on this link:

[]
[1]: https://i.stack.imgur.com/myV0N.jpg

Here we go:

1. Parent component

const BookingComponent = () => {
  return (
    <div>
      <CRContainer className="booking-crcontainer">
        <CRColumn>
          <PickUpCarComponent />
        </CRColumn>
        <CRColumn>
          <CustomerInfo />
        </CRColumn>
      </CRContainer>
      <CRContainer className="booking">
        <Button type="submit" btnText="hello there" />
      </CRContainer>
    </div>
  );
};

export default BookingComponent;

2. Child 1

const CustomerInfo = (props) => {
  const firstlRef = useRef();
  const lastNameRef = useRef();

  const onTrigger = (e) => {
    e.preventDefault();
    //console.log(first1Ref.current.value)
    console.log("heaheaheah");
  };

  return (
    <>
      <Subtitle stitle={SubtitleLabels.customerInfo} />
      <div className="customer-info-container">
        <form onSubmit={onTrigger}>
          <div>
            <LabeledInput
              labelText={CustomerInfoLabels.firstName}
              type="text"
              inputPlaceholder={GeneralLabels.placeholder}
              ref={firstlRef}
            ></LabeledInput>
            <LabeledInput
              labelText={CustomerInfoLabels.lastName}
              type="text"
              inputPlaceholder={GeneralLabels.placeholder}
              ref={lastNameRef}
            ></LabeledInput>
          </div> ...................

3. Child 2

Haven’t put the refs here yet.

const PickUpCarComponent = () => {
  return (
    <div>
      <Subtitle stitle={SubtitleLabels.pickUp} />
      <form>
      <div className="booking-inner-container">
        <div>
          <LabeledInput labelText={"Pick-up date*"} type="date"></LabeledInput>
          <LabeledInput labelText={"Pick-up time*"} type="time"></LabeledInput>
        </div>
        <DropDown type="CarGroup" labeltext="Car Group*" attribute="name" />
        <DropDown type="RentalOffice" labeltext="Region*" attribute="region" />
      </div>
     </form>
    </div>
  );
};

export default PickUpCarComponent;

4. Input Component

const LabeledInput = React.forwardRef((props, ref) => {
  const { labelText, type, inputPlaceholder, onChange, className } = props;

  return (
    <div className={`input-container ${className}`}>
      <label htmlFor="labelText">{labelText}</label>
      <input
        type={type}
        placeholder={inputPlaceholder}
        onChange={onChange}
        ref={ref}
      />
    </div>
  );
});

export default LabeledInput;

How to implement a simple box plot chart

I want to implement a chart like below.

enter image description here

But my problem is collision of the numbers in this chart and I couldn’t find a suitable solution for this. For example when two or three values are very close together, the collision happens. (the image below)

enter image description here

Get limits of a polygon in google maps

Dear communities have a greeting from me, I want to make a query, and that is that I am developing a map of coverage areas and I have been able to draw many areas on the map, in the code that I am going to share with you below I have only left 3 for Example and demonstration uses, now, what my code should do is that every time the google maps marker leaves the red polygon its value becomes false.

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <title>Electronica 2001</title>
      <meta name="description" content="Electronica 2001">
      <meta name="author" content="Electronica 2001">
      <!-- Favicon -->
      <link rel="shortcut icon" href="https://electronica2001es.com/images/favicon2.ico">
      <script type="text/javascript">
         WebFontConfig = {
            google: { families: [ 'Open+Sans:300,400,600,700,800','Poppins:300,400,500,600,700' ] }
         };
         (function(d) {
            var wf = d.createElement('script'), s = d.scripts[0];
            wf.src = 'assets/js/webfont.js';
            wf.async = true;
            s.parentNode.insertBefore(wf, s);
         })(document);
      </script> 
      <script type="text/javascript"></script> 
      <!-- Plugins CSS File -->
      <link rel="stylesheet" href="assets/css/bootstrap.min.css">
      <!-- Main CSS File -->
      <link rel="stylesheet" href="assets/css/style.min.css">
      <link rel="stylesheet" type="text/css" href="assets/vendor/fontawesome-free/css/all.min.css">
      <style>
         body {
         margin: 0; 
         padding: 0
         }
         html, 
         body, 
         #map {
         height: 100%; 
         font-family: Arial, sans-serif; 
         font-size: .9em; 
         color: #fff;
         }
         #note { 
         text-align: center;
         padding: .3em; 10px; 
         background: #009ee0; 
         }
         .bool {
         font-style: italic;
         color: #313131;
         }
         .info {
         display: inline-block;
         width: 40%;
         text-align: center;
         }
         .infowin {
         color: #313131;
         }
         #title,
         .bool{
         font-weight: bold;
         }
      </style>
      <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCA3CvqkU5D5dLfADaABJi3OxjoWL64keA&callback=initMap&libraries=places,geometry,drawing&v=weekly" defer></script>
   </head>
   <body onload="init()">
      <div id="note">
         <span id="title">&raquo;Inside the circle?&laquo;</span>
         <hr />
         <span class="info">Marker <strong>A</strong>: <span id="a" class="bool"></span></span> &larr;&diams;&rarr; <span class="info">Marker <strong>B</strong>: <span id="b" class="bool"></span></span>
      </div>
      <div id="map">test</div>
      <p id="demo"></p>
      <script src="assets/js/jquery.min.js"></script> 
      <script src="assets/js/bootstrap.bundle.min.js"></script> 
      <script src="assets/js/plugins.min.js"></script> 
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script> 
      <script>
         function sueltala() {
           Swal.fire({
           icon: 'success',
           title: '¡Información importante!',
           text: 'Something went wrong!',
           footer: '<a href>Why do I have this issue?</a>'
         })
         }
      </script> 
      <!-- Main JS File --> 
      <script src="assets/js/main.min.js"></script> 
      <script>
         var x = document.getElementById("demo");
         window.onload = function init() {
           if (navigator.geolocation) {
         navigator.geolocation.getCurrentPosition(showPosition);
         } else {
         x.innerHTML = "Geolocation is not supported by this browser.";
         }
         function showPosition(position) {
         x.innerHTML = position.coords.latitude + "," + position.coords.longitude;
         var
         contentCenter = '<span class="infowin">Center Marker (draggable)</span>',
         contentA = '<span class="infowin">Marker A (draggable)</span>',
         contentB = '<span class="infowin">Marker B (draggable)</span>';
         var
         latLngCenter = new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
         latLngCMarker = new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
         latLngA  = new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
         latLngB = new google.maps.LatLng(38, -93),
         coords = [ [ [-89.19868711734125, 13.69215075483513], [-89.19807557368586, 13.691410653984653], [-89.19831965470621, 13.690871212812844], [-89.19834915900537, 13.69033177040379], [-89.19825796389887, 13.690128501928752], [-89.19697050357172, 13.690097229840053], [-89.19645551944086, 13.69013371394311], [-89.19598345065424, 13.690670550805194], [-89.19385914111444, 13.691295990264242], [-89.19233564639399, 13.691963123853995], [-89.19868711734125, 13.69215075483513], [-89.19868711734125, 13.69215075483513], [-89.19868711734125, 13.69215075483513]], [ [-89.19570795712826, 13.673281378361137], [-89.19570795712826, 13.673281378361137], [-89.19570795712826, 13.673281378361137], [-89.19654480634091, 13.673281378361137], [-89.19667355237362, 13.671175564389776], [-89.19562212643979, 13.6697786279033], [-89.1954075497186, 13.670612620832053], [-89.19602982221005, 13.67232229710495], [-89.19570795712826, 13.673281378361137]], [ [-89.18643520663386, 13.704821815720464], [-89.18654249499446, 13.703946250391347], [-89.1831092674554, 13.703550160242049], [-89.18302343676692, 13.70413387180797], [-89.18403194735652, 13.70430064627475], [-89.18403194735652, 13.704592501306768], [-89.1865854103387, 13.704842662474233], [-89.18643520663386, 13.704821815720464], [-89.18643520663386, 13.704821815720464]]],
         map = new google.maps.Map(document.getElementById('map'), {
          zoom: 7,
          center: latLngCenter,
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          mapTypeControl: false
         }),
         markerCenter = new google.maps.Marker({
          position: latLngCMarker,
          title: 'Center of Circle',
          map: map,
          draggable: true
         }),
         infoCenter = new google.maps.InfoWindow({
          content: contentCenter
         }),
         markerA = new google.maps.Marker({
          position: latLngA,
          title: 'A',
          map: map,
          label: 'A',
          draggable: true
         }),
         infoA = new google.maps.InfoWindow({
          content: contentA
         }),
         markerB = new google.maps.Marker({
          position: latLngB,
          title: 'B',
          map: map,
          label: 'B',
          draggable: true
         }),
         infoB = new google.maps.InfoWindow({
          content: contentB
         })
         // exemplary setup: 
         // Assumes that your map is signed to the var "map"
         // Also assumes that your marker is named "marker"
         ,
         /* circle = new google.maps.Circle({
          map: map,
          clickable: false,
          // metres
          radius: 100000,
          fillColor: '#fff',
          fillOpacity: .6,
          strokeColor: '#313131',
          strokeOpacity: .4,
          strokeWeight: .8
         }); */
        bounds = new google.maps.LatLngBounds();
      for (var i = 0; i < coords.length; i++) {
      var polygonCoords = [];
      for (var j = 0; j < coords[i].length; j++) {
        var pt = new google.maps.LatLng(coords[i][j][1], coords[i][j][0])
        bounds.extend(pt);
        polygonCoords.push(pt);
      }
      // Construct the polygon.
      circle = new google.maps.Polygon({
        paths: polygonCoords,
        strokeColor: '#FF0000',
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: '#FF0000',
        fillOpacity: 0.35,
        map: map
      });
      };
         // attach circle to marker
         circle.bindTo('center', markerCenter, 'position');

         google.maps.Polygon.prototype.getBounds = function() {
    var bounds = new google.maps.LatLngBounds();

    this.getPaths().forEach(function(path) {
        path.forEach(function(point) {
            bounds.extend(point);
        });
    });

    return bounds;
};
         
         var
         // get the Bounds of the circle
         bounds = circle.getBounds()
         // Note spans
         ,
         noteA = jQuery('.bool#a'),
         noteB = jQuery('.bool#b');
         
         noteA.text((100000 > google.maps.geometry.spherical.computeDistanceBetween(markerA.getPosition(),markerCenter.getPosition())));
         noteB.text((100000 > google.maps.geometry.spherical.computeDistanceBetween(markerB.getPosition(),markerCenter.getPosition())));
         
         // get some latLng object and Question if it's contained in the circle:
         google.maps.event.addListener(markerCenter, 'dragend', function() {
         latLngCenter = markerCenter.position;
         noteA.text((100000 > google.maps.geometry.spherical.computeDistanceBetween(markerA.getPosition(),markerCenter.getPosition())));
         noteB.text((100000 > google.maps.geometry.spherical.computeDistanceBetween(markerB.getPosition(),markerCenter.getPosition())));
         });
         
         google.maps.event.addListener(markerA, 'dragend', function() {
         latLngA = markerA.position;
         noteA.text((100000 > google.maps.geometry.spherical.computeDistanceBetween(markerA.getPosition(),markerCenter.getPosition())));
         });
         
         google.maps.event.addListener(markerB, 'dragend', function() {
         latLngB = markerB.position;
         noteB.text((100000 > google.maps.geometry.spherical.computeDistanceBetween(markerB.getPosition(),markerCenter.getPosition())));
         });
         
         google.maps.event.addListener(markerCenter, 'click', function() {
         infoCenter.open(map, markerCenter);
         });
         
         google.maps.event.addListener(markerA, 'click', function() {
         infoA.open(map, markerA);
         });
         
         google.maps.event.addListener(markerB, 'click', function() {
         infoB.open(map, markerB);
         });
         
         google.maps.event.addListener(markerCenter, 'drag', function() {
         infoCenter.close();
         noteA.html("draggin&hellip;");
         noteB.html("draggin&hellip;");
         });
         
         google.maps.event.addListener(markerA, 'drag', function() {
         infoA.close();
         noteA.html("draggin&hellip;");
         });
         
         google.maps.event.addListener(markerB, 'drag', function() {
         infoB.close();
         noteB.html("draggin&hellip;");
         });
         }
         };
      </script>
   </body>
</html>

Displaying and modifying the content of an html div stored in a database

I’m working on a project and I want to record all the content of a html to store it in a database and also to be able to display it so I can modify it later.

I did this with javascript (but I only manage to save the ‘label’, the other fields are not saved I don’t know why) and I have this which is therefore saved on my database :

Form content picture

data received in the ‘formulaire’ field of my database :
Data recorded in the database

So I also want to know how to display the same content that is in my database (and that is encoded in a different way)

the page code :

            <form id="form-builder" method="post" action="{{route('submit')}}" enctype='multipart/form-data'>
                @csrf

                @if(session()->has('message'))
                    <div class="alert alert-success close-message">
                        {{ session()->get('message') }}
                    </div>
                @endif

                <input type="hidden" id="form-data" name="formulaire" value="">
                <div class="box-rightsave @error('formulaire') is-invalid @enderror" id="contents-2" style="min-height: 150px" name="formulaire" id="formulaire">
                {{ old('formulaire') }}
                </div>
            </form>

and the javascript code :

window.jsPDF = window.jspdf.jsPDF;
const doc = new jsPDF({
    orientation: "landscape",
    unit: "in",
    format: [4, 2],
});
var specialElementHandlers = {
    '#editor': function (element, renderer) {
        return true;
    }
};

const db = localStorage;

const _ = (el) => {
    return document.querySelector(el);
};

const getTpl = (element) => {
    return tpl[element];
};

const makeEditable = () => {
    let elements = document.querySelectorAll('.drop-element');
    let toArr = Array.prototype.slice.call(elements);
    Array.prototype.forEach.call(toArr, (obj, index) => {
        if (obj.querySelector('img')) {
            return false;
        } else {
            obj.addEventListener('click', (e) => {
                e.preventDefault();
                obj.children[0].setAttribute('contenteditable', '');
                obj.focus();
            });
            obj.children[0].addEventListener('blur', (e) => {
                e.preventDefault();
                obj.children[0].removeAttribute('contenteditable');
            });
        }
    });
};

const removeDivsToSave = () => {
    let elements = document.querySelectorAll('.drop-element');
    let toArr = Array.prototype.slice.call(elements);
    let html = '';
    Array.prototype.forEach.call(toArr, (obj, index) => {
        obj.children[0].removeAttribute('contenteditable');
        html += obj.innerHTML;
    });
    return html;
};

const tpl = {
    'header1': '<label>Entrez un label</label>',
    'header2': '<input class="form-control"/>',
    'header3': '<textarea rows="10" cols="30"></textarea>',
    'shortparagraph': '<select class="form-control" id="cars"><option value="volvo">Valeur1</option> <option value="saab">Valeur2</option> <option value="fiat">Valeur3</option> <option value="audi">Valeur4</option> </select>',
    'image': '<input type="file" name="file" id="inputGroupFile02">'
};

/**
 * init dragula
 *
 * @type  function
 */
const containers = [_('.box-left'), _('.box-rightsave')];
const drake = dragula(containers, {
    copy(el, source) {
        return source === _('.box-left');
    },
    accepts(el, target) {
        return target !== _('.box-left');
    }
});
dragula([document.getElementsByClassName('.drop-element')], {
    removeOnSpill: true
});


drake.on('out', (el, container) => {
    console.log(el)
    if (container == _('.box-rightsave')) {
        el.innerHTML = getTpl(el.getAttribute('data-tpl'));
        el.className = 'drop-element';
        if (el.getAttribute('data-tpl') != "image") {
            makeEditable();
        }
        db.setItem('savedData', _('.box-rightsave').innerHTML);
    }
    if (container == _('.box-left')) {
        el.innerHTML = el.getAttribute('data-title');
    }
});

if (typeof db.getItem('savedData') !== 'undefined') {
    _('.box-rightsave').innerHTML = db.getItem('savedData');
    makeEditable();
}
;

_('.reset').addEventListener('click', (e) => {

    e.preventDefault();
    db.removeItem('savedData');
    if (confirm('En êtes-vous sûr !?')) {
        _('.box-rightsave').innerHTML = '';
    }
});

_('.save').addEventListener('click', (e) => {
    e.preventDefault();
    var blob = new Blob([removeDivsToSave()], {
        type: 'text/html;charset=utf-8'
    });
    db.setItem('savedData', _('.box-rightsave').innerHTML);
});


//


$(document).ready(function () {
    // $(document).on("click","input[name=file]",function () {
    //     console.log($('.custom-file-input').click());
    //     // $(this)[0].trigger("click");
    //     // $(this).trigger("input[name=file]");
    //
    //
    // });

    $(document).on("dblclick", ".drop-element", function () {
        $(this).remove();
        db.removeItem('savedData');
        db.setItem('savedData', $("#contents-2").html())
    })
    setTimeout(function () {
        $(".close-message").hide();
    }, 2000)
    $(".form-submit").on("click", function (e) {
        e.preventDefault();
        $("#form-data").val(JSON.stringify($("#contents-2").html()));
        $("#form-builder").submit();
    });
    $(".save").on("click", function () {
        html2canvas(document.querySelector("#contents-2")).then(canvas => {
            document.body.appendChild(canvas)
            var myImage = canvas.toDataURL("image/jpeg,1.0");
            // Adjust width and height
            var imgWidth = (canvas.width * 120) / 650;
            var imgHeight = (canvas.height * 70) / 340;
            // jspdf changes
            var pdf = new jsPDF('p', 'mm', 'a4');
            pdf.addImage(myImage, 'png', 15, 2, imgWidth, imgHeight); // 2: 19

            pdf.save(`FormBuilderPDF.pdf`);
        });


    })
})

I hope you can help me

TypeError: The “original” argument must be of type Function in Vue.js application

I’m trying to call a soap webservice using the ‘soap’ module in my Vue SPA, but I get this error just by importing the module. I already searched a lot but didn’t find a solution.

My code:

// /src/services/soapService.js
import soap from 'soap';

var soapService = {

    users: {
        getAllUsers() {
            const url = 'http://127.0.0.2:8000/?wsdl'

            soap.createClient(url, function(err, client) {
                client.getAllUsers(function(err, result) {
                    console.log(result);
                })
            })
        }
    }
}

export default soapService;

Then I call my function in a Vue component:

<template>
  <div></div>
</template>

<script>
import soapApi from '@/services/soapService'

export default {
  name: 'Users',

  methods: {
    getAllUsers() {
      this.allUsers = soapApi.users.getAllUsers();
    }
  },

  mounted() {
    this.getAllUsers();
  }

}
</script>

When I try to load the Users.vue component, I get this error:

TypeError: The "original" argument must be of type Function
    at promisify (util.js?3022:602)
    at eval (index.js?4f62:7)
    at Object.../node_modules/get-stream/index.js (0.js:529)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at eval (client.js?e3c8:24)
    at Object.../node_modules/soap/lib/client.js (0.js:586)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at Object.eval (soap.js?3fc0:19)
abort @ vue-router.esm.js?8c4f:2316
eval @ vue-router.esm.js?8c4f:2369
eval @ vue-router.esm.js?8c4f:2138
eval @ vue-router.esm.js?8c4f:2203
Promise.then (async)
eval @ vue-router.esm.js?8c4f:2150
eval @ vue-router.esm.js?8c4f:2171
eval @ vue-router.esm.js?8c4f:2171
flatMapComponents @ vue-router.esm.js?8c4f:2170
eval @ vue-router.esm.js?8c4f:2106
iterator @ vue-router.esm.js?8c4f:2362
step @ vue-router.esm.js?8c4f:2004
step @ vue-router.esm.js?8c4f:2008
step @ vue-router.esm.js?8c4f:2008
step @ vue-router.esm.js?8c4f:2008
runQueue @ vue-router.esm.js?8c4f:2012
confirmTransition @ vue-router.esm.js?8c4f:2392
transitionTo @ vue-router.esm.js?8c4f:2260
push @ vue-router.esm.js?8c4f:2715
push @ vue-router.esm.js?8c4f:3037
handler @ vue-router.esm.js?8c4f:1139
invokeWithErrorHandling @ vue.runtime.esm.js?2b0e:1863
invoker @ vue.runtime.esm.js?2b0e:2188
original._wrapper @ vue.runtime.esm.js?2b0e:6961

Node v16.11.1
npm v8.1.3
vue v2.6.11

check the radio button when click on the li using javascript

I have radio button

Html code:

<input type="radio" class="first" name="bright" checked>
<input type="radio" class="second" name="bright" >
<input type="radio" class="third" name="bright">
<input type="radio" class="four" name="bright">

And i have a nav bar

Html code

<ul class="nav">

<li class="st st1 active" data-cont="first">
<h2 class="inner">وزارة الاستثمار</h2>
</li>
<li class="st st2" data-cont="second">
<h2 class="inner">وزارة التجارة</h2>
</li>
<li class="st st3" data-cont="third">
<h2 class="inner">جهات حكومية اخرى</h2>
</li>
<li class="st st4" data-cont="four">
<h2 class="inner">مكتب هندسي</h2>
</li>
 </ul>

These 2 are conected with the data-cont that have the class of the radio button

I want when i click on the li the correct radio button be checked using javascript

I tried to make it using this code in JavaScript

let radio = document.querySelectorAll("input");
let radioArray = Array.from(radio);
let tabs = document.querySelectorAll(".nav li");
let tabsArray = Array.from(tabs);


tabsArray.forEach((ele) => {
    ele.addEventListener("click", function (e) {
        tabsArray.forEach((ele) => {
            ele.classList.remove("active");
        });
        e.currentTarget.classList.add("active");
       document.querySelector(e.currentTarget.dataset.cont).checked = true;
    });
});

I try to remove the active class from li and put it on the li where i click then i want the radio button be checked

Any body can help me on this?

js assign new input value to form object without enforcing datetime-local format

The datetime-local html input type accepts a value in the format 2021-12-04T18:45, however my app uses dates in the 2021-12-04 18:45 format, so I’m trying to change the value of the datetime-local input with JavaScript on form submit:

document.getElementById('myform').onsubmit = (event) => {
    let _form = event.target;
    _form.elements.namedItem('date_from').value = '2021-12-10 20:50';
};

but get the following error:

The specified value “2021-12-10 20:50” does not conform to the
required format. The format is “yyyy-MM-ddThh:mm” followed by
optional “:ss” or “:ss.SSS”.

How do I bypass the formatting enforcement in this scenario?

I’d prefer using datetime-local input type, to take advantage of the built-in date and time picker as opposed to having to use extra library. So changing the input field type would not be a preferable solution.

P.S. I cannot control the backend processing of the form, so I have to change the value in the frontend before the form is submitted further.

Unclear why Fetch for UPS XML API failing

I’m working on an airtable automation that is putting in an address validation request to the USPS API. For some reason, when I try to fetch it times out. I’ve validated that the URL I’m testing on works just fine and provides a response, but no matter what I try, I cannot get this to work.

AFAIK, using Fetch is the only way I can access the XML response in airtable automations. I’m open to anything that gets me the data (I know that because it’s an XML response I can’t parse it immediately.)

Here’s an example of a URL (with my ID marked out) that is failing:

let geo2 = await fetch( 'http://secure.shippingapis.com/ShippingAPI.dll?API=Verify&XML=<AddressValidateRequest%20USERID="00000000"><Address><Address1>null</Address1><Address2>7400%20Quebec Pl NW</Address2><City>Brooklyn</City><State>NY</State><Zip5>20202</Zip5><Zip4></Zip4></Address></AddressValidateRequest>').then(response => response.text())

I can’t find any similar errors online, and have found code in other places (not airtable) that has worked. Any idea why this isn’t working, and if there are alternatives that work in airtable? I can’t use XMLhttpRequest as far as I can tell.