What is the problem in code that alerts pop-up if I don’t enter my ID or password?

I want to make a program that If I don’t enter my ID or password, an alert pops up, and if my password is less than 6 characters, an alert pops up.

When I ran this code, the ‘Fill in the blank’ and ‘Enter the password with at least 6 characters’ alerts always appeared even if I type letters in the ID and password boxes. If the condition is false, the alerts should not be displayed, but why does it appear? I don’t know what the problem is.

        <form action="success.html">
    
    <div class = "my-3">
    <input type = "text" class = "form-control" id="id" placeholder="Fill in the blank">
    </div>
<div class="my-3">
    <input type = "password" class = "form-control" id="pw" placeholder="Enter the password with at least 6 characters">
</div>

<button type = "submit" class = "btn btn-primary">전송</button>
<button type = "button" class = "btn btn-danger" id="close">닫기</button>

</form>

var Text1 = $(‘#id’).val();
var Password1 = $(‘#pw’).val();
var passwordLength = $(‘#pw’).val().length;

$(‘form’).on(‘submit’, function() {
if ( “Text1 == ”” || “Password1 == ””) {
alert(‘Fill in the blank’)
}

if (passwordLength

jQuery event listener not working on multiple elements?

const date = document.getElementById("date");
const time = document.getElementById("time");
const d_t = document.getElementById("showDate-Time");

$(document).ready(function () {
  $("#date").change(function () {
    d_t.innerHTML = `${date.value} ${time.value}`;
  });
  $("#time").change(function () {
    d_t.innerHTML = `${date.value} ${time.value}`;
  });
});

Whenever I change the date value the function gets called but when I change the time value it does’t get called. If I switch their order only the first one gets triggered.

Is there a way to make a click event have the same behavior as after clicking a link?

When we click a link like <a href="https://stackoverflow.com/">A link</a>, the current page will be redirected to the given URL. But we’ll be led to a new tab if we cmd/ctrl+click it. I wonder that is there a browser interface(something like window.open()) in JS that can give the click event of a non-a tag the same behavior above? The solution I got from the Internet is all about detecting e.metaKey/ctrlKey to decide whether to add _blank to the window.open() or not. The solution is tricky and still has some differences from the expected behavior. Maybe we can just simply use the <a> tag directly to avoid this. But can this be the solution for all situations? And could you guys please give me the reason if there’s indeed not a pure JS way to simulate the event? Cuz it’s weird to me.

How to compare a value with each item of range – Appscript

for the last 3 days (my first 3 days of coding) i’ve been trying to code an script to get my google contacts that have certain keyword, it being “Catamarca”, on their name and also to delete that keyword after they’ve been added to the spreadsheet leaving only their name.

I’ve been succesfull in all of this. But now i want to only run the script on an existing database, and only run it if the new contacts are not on the sheet already, and not write over the existing ones.

Here is my code so far:


function impContacts() {

  // variables

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("GContacts");
  var grupo = ContactsApp.getContactGroupById("http://www.google.com/m8/feeds/groups/[email protected]/base/6")
  const contactos = grupo.getContacts();
  const arraycontacts = [];


  // get the last row on B with data on it


  const lastRow = sheet.getLastRow();
  const Avals = sheet.getRange("B2:B" + lastRow).getValues();
  const Alast = lastRow - Avals.reverse().findIndex(c => c[0] != '');
  Logger.log(Alast);

  var rangeInteres = sheet.getRange(2, 1, Alast, sheet.getLastColumn()).getValues();

  // look for contacts that has in their name the word "Catamarca", and save them with their id, name and phone.

  contactos.forEach(contacto => {
    var phone = ""
    if (contacto.getPhones()[0]) {
      phone = contacto.getPhones()[0].getPhoneNumber()
    };
    var name = ""
        if (contacto.getFullName().match("Catamarca")){
      name = contacto.getFullName();
    };
    
        var idcont = ""
    if (name == rangeInteres.forEach(namme => 
    {
      oldName = namme[1];
      Logger.log(oldName);}))
    {
      idcont =
        rangeInteres.forEach(id => {
          oldId= id[0];
          Logger.log(oldId);})
    }
    else 
    {
      idcont = contacto.getId().replace(/D/g, '')
    };
    
    const datoscont = [idcont, name, phone];
    arraycontacts.push(datoscont);

  })

  // save new contact

  sheet.getRange(2, 1, arraycontacts.length, 3).setValues(arraycontacts);

  // look for "catamarca"

  range = sheet.getRange("B2:B")
  var textFind = range.createTextFinder("Catamarca");
  textFind.matchEntireCell(false);
  textFind.ignoreDiacritics(true);
  textFind.matchCase(false);
  var textFound = textFind.findNext();

  // Si encuentra coincidencia reemplazar por ""

  if (textFound !== null) {
    var vals = textFound.getValues();
    textFind.replaceAllWith("");
  }
}

What i need to keep the most is the ID of the existing contacts (the IDs are different from the ones coming from google contacts but the names are the same), because they are linked to an app created using AppSheet.

I believe there should be a way to accomplish this by editing this part of the code

    var idcont = ""
    if (name == rangeInteres.forEach(namme => 
    {
      oldName = namme[1];
      Logger.log(oldName);}))
    {
      idcont =
        rangeInteres.forEach(id => {
          oldId= id[0];
          Logger.log(oldId);})
    }
    else 
    {
      idcont = contacto.getId().replace(/D/g, '')
    };

In my head and with my current knowledge, the code should be working, but it’s not, I mean, it runs, but overwrites everything.

Hope someone can help me.

Regards,

Federico.

React-js MUI Tooltip overlapping Popper

I want the MUI tooltip to go beneath the MUI Popper that is popper should overlap the tooltip. If I override the “MuiTooltip” or “MuiTooltip-popper”s z-index using external css, it’s getting applied globally, which I don’t want.

Is there a way to override either tooltip or popper behaviour & modify the z-index only for some portion ?

sandbox: https://codesandbox.io/s/tooltip-popper-issue-myryfv?file=/src/App.js

note: If the popper in the sandbox is not in the center, try to modify the code. Let the error appear & undo the modification.

I am using MUI v4

Tooltip over Popper

why is my cookie not saving on the browser?

I have this block of code and when a user login, it should set the “access_token” cookie to a token, but when i check the browser application cookie, i see nothing and user is unauthenticated.

const login = async (req, res) => {
  try {
      const oneUser = await Users.findOne({ username: req.body.username });
if (!oneUser) {
    return res.status(403).json("No such user in the database");
}

const isPassword = await bcryptjs.compare(
    req.body.password,
    oneUser.password
);

if (!isPassword) {
    return res.status(500).json("Password is incorrect");
}

const token = jwt.sign(
    {
        id: oneUser._id,
        isAdmin: oneUser.isAdmin,
    },process.env.jwt);

const { password, ...others } = oneUser._doc;
res.cookie("access_token", token).status(200).json({ ...others });
} catch (err) {
    res.status(500).json(err);
}

};

We provide a restaurant listing and reservation system to restaurants and free on-line bookings for diners

Favouritetable’s table booking system provides you with measures like reviews, pictures, menu, and other infrastructural facilities such as wheel-chair accessibility and child-friendliness. The restaurants are sorted under various categories such as Romantic Restaurants, Breakfast, vegan, al fresco restaurants and many more, to help you find the best restaurants near you.

Whether it’s a casual get together, a family dinner or a romantic date. Favouritetable has got you covered. The most trusted factor when it comes to choosing the best restaurant near you is the reviews of your fellow diners. The review section helps you find what exactly people like about a particular restaurant you’re looking to dine at. Favouritetable helps you find location-specific restaurants.
Just type your city name such as London, Bristol, Chester, Manchester and find the best restaurant near you.

We believe in making technology simple, resilient, highly functional and scalable, whilst providing real added value and exemplary customer service”

At favouritetable, we work extremely hard on our customers’ behalf, in order to create as much awareness as possible about their restaurant(s). In addition to enabling bookings on the restaurant’s website, we also strive to bring new business through the door, on a daily basis.

Our packages for restaurants and pubs operators offer real added value and include:

• Affordable online restaurant reservation system with no per guest booking fees or long term contract;
• Complementary Social Media exposure for our customers, through www.favouritetable.com, twitter and Facebook
• A stable of targeted and specialised on-line publications;
• Reservations taken from restaurants’ websites, www.favouritetable.com, Facebook and restaurants bloggs;
• Promotions through our regular newsletters;

We save our customers an average of 70% + on their existing on-line reservation booking cost!

How to map json object data to datatables using Jquery

I have a JSON object data that am getting from an api call. How can I map it to two columns.
This is the JSON Object

[
    {
        "id": 322,
        "uploadStatus": 0,
        "labName": "CS Minhewene"
    },
    {
        "id": 323,
        "uploadStatus": 0,
        "labName": "CS Nacuale"
    },
    {
        "id": 324,
        "uploadStatus": 0,
        "labName": "CS Mesa"
    },
    {
        "id": 325,
        "uploadStatus": 0,
        "labName": "CS Metoro"
    },
    {
        "id": 326,
        "uploadStatus": 0,
        "labName": "CS Ngewe"
    },
    {
        "id": 327,
        "uploadStatus": 0,
        "labName": "CS Mariri"
    }
]

Whenever I try to map it I get a datatable error

DataTables warning: table id=tableBody – Requested unknown parameter
‘0’ for row 0, column 0. For more information about this error, please
see http://datatables.net/tn/4

This is my implementation

$.ajax({
                            type: 'GET',
                            contentType: "application/json; charset=utf-8",
                            url: 'api/getuploadbydistricts/'+this.name,
                            success: function (data) {
                                myJsonData = data;
                                console.log('data 2', myJsonData);
                                populateDataTable(JSON.stringify(myJsonData));
                                $('#tableBody').dataTable().fnDestroy();
                                },
                                 error: function (e) {
                                    console.log("There was an error with your request...");
                                    console.log("error: " + JSON.stringify(e));
                                    }
                                    });
                                    // populate the data table with JSON data
                                    function populateDataTable(data) {
                                        console.log("populating data table...");
                                        console.log('data 2', data.uploadStatus);
                                        $('#tableBody').dataTable().fnDestroy();
                                        $("#tableBody").DataTable().clear();
                                        $('#tableBody').dataTable().fnAddData( [
                                        data.uploadStatus,
                                        data.labName,
                                        ]);
                                        // clear the table before populating it with more data
                                    }

How can I display the json object to the datatable correctly, an help is appreciated

Format data returned from JSON in DataTable

I am reading a json file from remote url and displaying it in DataTable.

<script>
    $(document).ready(function () {
        $('#example').DataTable(
            {
            ajax: {
                method: 'GET',
                url: 'https://chainformed.s3.us-east-1.amazonaws.com/Data/mostwatched.json',
                dataSrc: ''
            },
            paging: false,
            responsive: true,
            language: {
    url: "//cdn.datatables.net/plug-ins/1.12.1/i18n/tr.json",
  },

            columns: [
                { "data": "id" },
                { "data": "rank" },
                { "data": "name" },
                { "data": "watchlist" },
                { "data": "percentage" },
                { "data": "difference" },
                { "data": "timestamp" }
                
            ]
        });
        $('.dataTables_length').addClass('bs-select');
    });
</script>

I would like to be able to format and manipulate the data returned from that json file. What is the best way to do it?

For example, i would like to change the values from ({ “data”: “watchlist” }) field to number format with comma. How can i achieve it?

I tried this but with no luck: https://datatables.net/reference/option/ajax.dataSrc

enter image description here

HOow the sereinthest and design?

Interaction design, also known as interaction design, is the field of design that defines and designs the behavior of man-made systems. Artifacts, ie, artificially made items, such as software, mobile devices, artificial environments, services, wearables, and the organization of systems. Interaction design is about defining the interface related to the way the artifact behaves (the “interaction”, that is, how the artifact reacts in a specific situation). Interaction design bridges information architecture and visual design to form an easier-to-use user interface.how much do sponsors pay

Google Apps Script – Returning Undefined

What I want to do:

  1. Submit the values from two textboxes (Last Name & First Name)
  2. Process the two values in Code.gs (Create a string in “Hello LastName, FirstName” format)
  3. Return back the processed value and display it to the third textbox.

Please note that I can do it if the processing of data is in html, but I want to practice doing it in Code.gs since I want to fiddle with Google Sheets in the future, I just wanted to study it little by little. But when I transferred the processing inside Code.gs, the returned data is “undefined”. Your help is very much appreciated. Thank you very much!

Present code:

Code.gs:

function doGet(e) {
  return HtmlService
    .createTemplateFromFile('Index').evaluate();
}

function getData(a,b){
  var lastName = a;
  var firstName = b;
  var txtResult = "Hello " + a + ", " & b;
  return txtResult;
}

Index.html:

<!DOCTYPE html>
<html>
  <body>
    <div>
      <label>Enter Last Name</label>
      <input type="text" id="txtLastName"/></br>
      <label>Enter First Name</label>
      <input type="text" id="txtFirstName"/></br>
      <button id="btnProcess">Process</button></br>
      <input type="text" id="txtResult"/>
    </div>
  </body>

  <script>
    document.getElementById("btnProcess").addEventListener("click", processData);                
    function processData() {
      var lastName = document.getElementById("txtLastName").value
      var firstName = document.getElementById("txtFirstName").value
      document.getElementById("txtResult").value = google.script.run.getData(lastName,firstName);
    }
  </script>
    
</html>

How can i make to reenter my input fields?

I have a form which shows an alert with a message when the two password input fields do not match but if they do match it shows a confirmation message before creating the user. The issue im having is that even if they dont match my form is being sent after the alert message. How can i do so that this doesnt happens?

<script>
    
        function confirmarAlta(){
            
            var result = confirm("Esta seguro que desea crear este usuario?");
            
            if(result == false){
                event.preventDefault();
            }
        }
    
    </script>

    <script>
        function verificarPassword(){
            var pass = document.querySelector(".password").value;
            var confirmPass = document.querySelector(".confirmPassword").value;
            console.log(pass);
            console.log(confirmPass)
            
            if(pass != confirmPass){
                pass = "";
                confirmPass = "";
                alert("Las contraseñas no coinciden");
                return 
            }
        
        }   
    
    </script>

    <script>
    
        function Validaciones(){
            verificarPassword();
            
            if(verificarPassword()==true){
                
                confirmarAlta();
            }
        }
    
    
    </script>
<div class="form-group">
        <label>Contraseña: </label>
        <input type="password" class="form-control password" name="txtPassword" required>
      </div>
      <div class="form-group">
        <label>Repetir Contraseña: </label>
        <input type="password" class="form-control confirmPassword"  name="txtConfirmarPassword" required>
      </div>

      <div class="col-12">
        <input onclick="Validaciones()" type="submit" class="btn btn-success" value="Aceptar" name="btnAceptar">
        <button type="submit" class="btn btn-outline-info">Limpiar campos</button>
    </div>

table data is clear after submitting the form

I am working with javascript

when I submit the form I store the data in a table but the table data is also clear

index.html

<body>
<form id='freg'>

  <label>firstname</label>
  <input type='text' id='fname'>

  <label>lastname</label>
  <input type='text' id='lname'>

  <label>officelocation</label>
  <input type='text' id='location'>

  <input id='btn' type='submit' value='submit' onclick='onFormSubmit()'/>

</form>
<br/> <br/>

<table>
   <thead>
      <tr>
        <th>firstname</th>
        <th>lastname</th>
        <th>location</th>
      </tr>
    </thead>
    <tbody>
       <td id='ffname'></td>
       <td id='llname'></td>
       <td id='olocation'></td>
    </tbody>
</table>

<script type='text/javascript' src='index.js'></script>


index.js


function onFormSubmit() {


 document.getElementById('fname').value;
 document.getElementById('lname').value;
 document.getElementById('location').value;

 readFormData();

}

function readFormData() {

var data = {};

data.fname = document.getElementById('fname').value;
data.lname = document.getElementById('lname').value;
data.location = document.getElementById('location').value;

insertnewrecord(data);

}

function insertnewrecord(data) {

document.getElementById('ffname').innerHTML = data.fname;
document.getElementById('llname').innerHTML = data.lname;
document.getElementById('olocation').innerHTML = data.location;


  resetform();

}

function resetform() {

document.getElementById('fname').value = "";
document.getElementById('lname').value = "";
document.getElementById('location').value = "";

}




I am working with html with javascript

when I submit the form then not able to see the data in table I put debug and I can see the data is store in table but then tabale data is clear.

Can someone help me, i run my code and got this ooutput : TypeError: eventType.toBuffer is not a function

I run this code in my visual code studio, i make 2 server: producer and consumer. The consumer is done, this is producer part:

    const Kafka = require('node-rdkafka');
    const eventType = require('../eventType.js');

    const stream = Kafka.Producer.createWriteStream({
      'metadata.broker.list': 'localhost:9092'
    }, {}, {
      topic: 'test'
    });

    stream.on('error', (err) => {
      console.error('Error in our kafka stream');
      console.error(err);
    });

    function queueRandomMessage() {
      const category = getRandomAnimal();
      const noise = getRandomNoise(category);
      const event = { category, noise };
      const success = stream.write(eventType.toBuffer(event));     
      if (success) {
        console.log(`message queued (${JSON.stringify(event)})`);
      } else {
        console.log('Too many messages in the queue already..');
      }
    }

    function getRandomAnimal() {
      const categories = ['CAT', 'DOG'];
      return categories[Math.floor(Math.random() * categories.length)];
    }

    function getRandomNoise(animal) {
      if (animal === 'CAT') {
        const noises = ['meow', 'purr'];
        return noises[Math.floor(Math.random() * noises.length)];
      } else if (animal === 'DOG') {
        const noises = ['bark', 'woof'];
        return noises[Math.floor(Math.random() * noises.length)];
      } else {
        return 'silence..';
      }
    }

    setInterval(() => {
      queueRandomMessage();
    }, 3000);

But, i got this output:

TypeError: eventType.toBuffer is not a function
at queueRandomMessage