I am trying to print the data of my form in html and check if the user password is same ans confirm password

I tried this and my console just gave me two empty lines for the console.log(password.value) and console.log(confirm_pass.value)

Also I get an error about ‘incorrect use of <label for=form_Element>‘ issue in the html inspect section

var password = document.getElementById("pass");
console.log(password.value);
conifrm_pass = document.getElementById("pass_conf");
console.log(password.value);
console.log(conifrm_pass.value);

if (password.value != conifrm_pass.value) {
  alert("The password and confirm password don't match");
}

how to use tags in text in shoutbox

I want to have some kind of shoutbox with tags in html (server side is php and mysql).
I need 3 kinds of tags (persons, items, sockets).
I think that i need to use some JS script to do that.
Tags will be defined before text is writing.
I have no idea how to get in JS (I know how to use ajax and server side) defined tags when typing Tags could be prefixed by # @ $ (in text this signs wold be not used) and after that it is looking in DB to tag (like autospeeling it is looking and user could click in them if its correct)?

I am in design stage.
I know how make SQL tables with tags.
I know how make AJAX PHP side.
I need help to do it right way, only JS is problem for me… and general idea could be bad.

Handling concurrent updates to dynamodb without overwriting

Firstly, I have seen this question and understand the takeaways from the points made.

However I’m unsure how I can improve my current situation.

I have a placeholder entry in my DynamoDB that will be updated when I receive data from an SQS queue that itself receives sporadic data processed via an external API.

The data in my table looks something like:

    {
      name: "ID",
      type: "S",
    },
    {
      name: "RESULTS",
      type: "L"
    }

With the ID being the key and the RESULTS being an array of result object that are sent in.

So an example would be

{
  ID: "ID123",
  RESULTS: [{resultId: 1, result: 'fail'}, {resultId: 2, result: 'pass'}]

The API that fires results for me to persist can fire quickly and concurrently, so I am needing to handle any race conditions.

Currently my plan is to:

  1. Pull the existing data for a specific ID
  2. Extract the RESULTS data
  3. Append the new results as received from the processing API
  4. Push the data back to the DynamoDB

The issue I’m thinking of is, how do I handle 2 sets of results coming in at the same time? If this were to happen, both requests would:

  1. Pull the same RESULTS data from the DB
  2. Append their own results to the data
    and when the data is persisted back, which ever one is last will overwrite the other…
// This is within a Lambda handler, just FYI

return await Promise.all(
      // event and Records refers to the SQS message coming through
      event?.Records?.map(async record => {
        const { body }: SQSRecord = record;
        const { id, data: { resultsFromApi } } = JSON.parse(body);

        const dbData = // fetch results from DB by ID

        const {RESULTS: { L: RESULTS }} = dbData?.Item;

        // Combine results
        const combonedResults = [...RESULTS, ...resultsFromApi]

        // store new results in DB alongside ID
        storeInDb(id, combonedResults);
      }),
    )

How can one implement concurrency to protect from the race conditions and overwrites?

FYI – I’m currently using the PutItemCommand rather than using the update variant just as I’m not too familiar with working on Dynamo – So if that will cause an issue also, let me know.

Excel VBA & IE : Input value to a prompt popup and enter

In short:

How do you 1. Focus on a prompt popup on IE, 2. Type in a value, and 3. Return?

In Long:

Hi,

I am trying to automate a login/file-downloading process on a company intranet server through VBA. I have gotten the log-in and navigating working, however am stuck on trying to download a file from the site.

The ‘Download’ works as follows:

  • When the ‘Download’ button is clicked, ‘createFileForDownload’ is triggered
  • Then the user is prompted to input a string
  • If there is no input, or if you click “cancel” on the popup it alerts an error message
  • If there is a valid input, it begins to compile a file and downloads it to the PC

CODE :

function createFileForDownload(){
    // Main function triggered when the 'Download' button is clicked
    var reason = getReasonForDownload();
    if (reason){
        //Retrieve data from server and create the file for downloading
    }
}

function getReasonForDownload(inputName){
    // The function I cannot get past
    var reasonForDownload = prompt("Specify the reason for your download", "");
    if (reasonForDownload  && reasonForDownload .length > 0) {
        return "<input type='hidden' name='" + inputName + "' value='" + reasonForDownload  +"'>";
    } else {
        alert("You must input a value");
        closeHiddenWaitingFrame();
        $('.waitingPop').removeClass("open"); //Close the waiting frame
        return false;
    }
}

PROBLEM:

However, when I try to access the prompt, it pauses the running VBA code.

Is there any way I could input a string to the prompt and ‘enter’?

What I have attempted so far:

SendKeys

  • only runs after the prompt is shown, and I am unable to change focus to the prompt without clicking it manually

Overwriting the OnClick method

  • I cannot override the enter onclick function, because the function itself contains the code to actually construct the file for downloading.
  • I was hoping there would be a way to overwrite the ‘getReasonForDownload’ function and return it, however it seems I would have to rewrite the entire ‘createFileForDownload’ function to achieve what I want.

Sorry about the lack of info; I cannot post the actual site or code online due to the company’s privacy issues.

Any help would be greatly appreciated: thank you so much in advance!

Export / import variables in different files

I have a function in func.js. And I also have some variables in vars.js.

How can I export variables from vars.js to func.js to use these variables within function in func.js?

I tried this case:

vars.js:

let var1 = "test1";
let var2 = "test2";
export { var1, var2};

func.js

import { var1, var2 } from '../vars.js';

index.cshtml:

<script type="module" src="~/vars.js" defer></script>
<script type="module" src="~/func.js" defer></script>

If I’m trying to log var1 and var2 to the console I get an error:

SyntaxError: Export ‘moduleNum’ is not defined in module

Please advise me how to export variables from one JS file to another?

ClassList property isn’t working when using an Event Listener [closed]

const heading = document.querySelectorAll('h2');
const para = document.querySelectorAll('.text');

heading.forEach((head, index) => {

  para[0].style.display = 'block';

  head.addEventListener('click', (e) => {

    e.target.classList.remove('.current');

    heading[index].classList.add('.current');

    para.forEach(pa => {
      pa.style.display = 'none';
    })

    para[index].style.display = 'block';
  })
})
.container {
  display: flex;
  flex-direction: column;
  width: 75%;
  margin: 0 auto;
  font-size: 14px;
}

.list {
  display: flex;
  width: 100%;
  justify-content: space-around;
  border-bottom: 1px solid lightgrey;
}

h2 {
  padding: 0;
  margin: 0;
  text-align: center;
}

.list .li {
  flex-basis: 25%;
}

.current {
  cursor: pointer;
  color: blue;
  border-bottom: 1px solid blue;
}

.text {
  display: none;
}
<div class="container">
  <div class="list">
    <div class="li list1">
      <h2 class="current">History</h2>
    </div>
    <div class="li list2">
      <h2>Playlists</h2>
    </div>
    <div class="li list3">
      <h2>Live Events</h2>
    </div>
    <div class="li list4">
      <h2>Highlights</h2>
    </div>
  </div>
  <div class="para-div">
    <div class="text">
      <p>1 Lorem ipsum dolor sit amet consectetur adipisicing elit. Ex commodi quam asperiores quod ducimus iste non blanditiis quis? Dolores fugit ullam debitis, sed odit laudantium asperiores accusamus delectus fuga sapiente.</p>
    </div>
    <div class="text">
      <p>2 Lorem ipsum dolor sit amet consectetur, adipisicing elit. Possimus optio, laudantium ipsa dolorem cum blanditiis ratione repellendus iusto maiores esse debitis vero porro saepe dolor unde quibusdam hic harum deserunt.</p>
    </div>
    <div class="text">
      <p>3 Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo autem necessitatibus, possimus expedita fuga fugiat eligendi veniam dolorum consectetur qui accusamus, error excepturi modi, eos esse asperiores assumenda. Nemo, sint.</p>
    </div>
    <div class="text">
      <p>4 Lorem ipsum dolor sit amet consectetur adipisicing elit. Illo in aspernatur laudantium quia quae saepe excepturi dolore assumenda aperiam nihil amet, facilis architecto quisquam eos tenetur facere illum doloremque necessitatibus!</p>
    </div>
  </div>
</div>

The idea is simple: when clicking on different headings, I want to apply the class to that heading (using the property of classList) but either way it isn’t working because there’s a problem with the .current class that I wrote in CSS code or the .current class isn’t applying to the heading at all. When the class is applied to a heading, the color of this heading text becomes blue, the cursor is pointer and it has colored border bottom.

Hope to understand how to solve this problem

multiple single select using slim select

I am attempting to clone a SlimSelect instance. However, after cloning the select element and trying to initialize the SlimSelect on the cloned element, I encounter a problem. The value of the cloned select element remains the same as the original one, and the dropdown menu fails to open. Could you assist me in identifying what might be missing or incorrect in my code?

const btn = document.getElementById("add-button");
const formClone = document.querySelector(".clone");
const parentForm = document.querySelector(".wrappers");
    
    btn.addEventListener("click", (e) => {
      e.preventDefault();
      const id = makeid(10);
      const clone = formClone.cloneNode(true);
      const arr = clone.querySelector("[name='ArrLists']").id;
      parentForm.appendChild(clone);
    
      const deleteForm = document.createElement("button");
      deleteForm.innerText = "X";
      deleteForm.classList.add("btn", "btn-danger", "btn-sm");
      clone.appendChild(deleteForm);
      
      new SlimSelect({
  select: arr
});
    
      deleteForm.addEventListener("click", (e) => {
        e.preventDefault();
        e.target.parentElement.remove();
      });
    });
    
new SlimSelect({
  select: '#single'
});
    
    function makeid(length) {
    let result = '';
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    const charactersLength = characters.length;
    let counter = 0;
    while (counter < length) {
      result += characters.charAt(Math.floor(Math.random() * charactersLength));
      counter += 1;
    }
    return result;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link href="https://unpkg.com/slim-select@latest/dist/slimselect.css" rel="stylesheet">

<button id="add-button" class="btn btn-primary mb-3">Add Form</button>
<div class="wrappers">
  <div class="row clone mb-2">
    <div class="col px-0">
      <select id="single" name="ArrLists">
        <option value="" selected disabled>Choose</option>
        <option value="value 1">Value 1</option>
        <option value="value 2">Value 2</option>
        <option value="value 3">Value 3</option>
      </select>
    </div>
  </div>
</div>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
<script src="https://unpkg.com/slim-select@latest/dist/slimselect.min.js"></script>

Get lable by nearest answer [closed]

samples = ["are you here?", "you are mad at me", "this is question?", "what is this"]

lables = ["YES", "NO", "YES", "QUESTION"]

In php-ml or js ml :

provdide a question like "are yu heree"
get label "YES"

i don’t know much about machine learning. and i’m just starting.

TypeError: Cannot create property ‘375’ on number ‘1’

I’m trying to create an algorithm visualiser for heap sort. In order to keep track of the swaps that happen during the heap sort execution, I created an animations array that will include the indexes of each swap. The heap sort animation works fine, but once I introduce the animations array into my code, I run into this error. TypeError: Cannot create property '375' on number '1'

Sort.js

heapSortVisualiser() {
    const animations = heapSort(this.state.array);
    console.log(animations);
}

HeapSort.js

// i is an index in arr, N is size of heap
function heapify(arr, N, i, animations) {
    let largest = i; // initialise largest as root
    let l = 2 * i + 1; // left = 2i + 1
    let r = 2 * i + 2; // right = 2i + 2

    // If left child is larger than root
    if (l < N && arr[l] > arr[largest]) { largest = l; }

    // If right child is larger than current largest
    if (r < N && arr[r] > arr[largest]) { largest = r; }

    // If largest is no longer the root
    if (largest !== i) {
        animations.push({
            type: 'heapify',
            index1: i,
            index2: largest
        })
        [arr[i], arr[largest]] = [arr[largest], arr[i]]; // swap i and largest

        // Recursively heapify the affected subtree
        heapify(arr, N, largest);
    }
}

export function heapSort(arr, animations = []) {
    let N = arr.length;

    // Build heap (rearrange array)
    for (let i = Math.floor(N / 2) - 1; i >= 0; i--) { heapify(arr, N, i, animations) };

    // Extract top element of heap one by one until heap is empty
    for (let i = N - 1; i > 0; i--) {
        animations.push({
            type: 'sort',
            index1: i,
            index2: 0
        })
        [arr[i], arr[0]] = [arr[0], arr[i]] // move current root to end

        // call max heapify on the reduced heap
        heapify(arr, i, 0, animations);
    }
    return animations;
}

Initially I thought the problem was pushing a JavaScript object to the array was the issue, so I used JSON.stringify() to convert the object to a string but the same error persists.

Not able to get inside the for loop in React js

I am making a To-Do App. I am using React frontend, Node backend, and Postgresql DB.
I made a component called <TaskLists /> which takes three properties or props:

  1. startDate
  2. endDate
  3. allTasks

allTasks is an array of task lists. Its basic structure is as follows:

allTasks = [
    {
        id: //taskList id
        list_date: //taskList date
        tasks: [
            {
                id: // task id
                title: // task title
                done: // boolean value either true or false
            }, ...
        ]
    }, ...
]

I am getting this allTasks array from my backend successfully as I can see from my react dev tool.

Using startDate and endDate, I am rendering all the task lists with their list_date b/w the two using the <TaskLists /> component.

I am trying to render today’s tasks (i.e. 19-07-2024) by the following code:

<TaskLists startDate={props.currentDate} endDate={props.currentDate} currentDate={props.currentDate} allTasks={props.allTasks} />

I made the startDate and endDate property same to currentDate (i.e. 19-07-2024) which I am getting from a parent component.

Now inside my <TaskLists /> component, I want to render either the list of tasks having list_date b/w startDate and endDate or I want to render a <TaskListAbsent /> component which renders if there is no task list b/w startDate and endDate.

So I made a useState() hook:

const [requiredTaskLists, setRequiredTaskLists] = useState([]);

Following is the code to set the variable requiredTaskLists:

const changeRequiredTaskLists = () => {
    let newTaskList = [];
    for(let i=0; i<props.allTasks.length; i++) {
      if(props.startDate <= props.allTasks[i].list_date && props.endDate >= props.allTask[i].list_date) {
        newTaskList.push(allTasks[i]);
      }
    }
    setRequiredTaskLists(newTaskList);
  }

And then I called the changeRequiredTaskLists() function in a useEffect() hook to call that function with every render:

useEffect(() => {
    changeRequiredTaskLists();
}, []);

And lastly, I am rendering the <TaskLists /> component as follows:

return (
    <>
      {
        requiredTaskLists.length !== 0 ? 
        <>
          {
            requiredTaskLists.map((taskList) => {
              // code for displaying every `taskList` from `requiredTaskLists` array.
            })
          }
        </> : 
        <>
          <TaskListAbsent />
        </>
      }
    </>
  )

But the problem is that for loop inside checkRequiredTaskLists is not getting executed. And I can confirm that with console logs.
Console logs just before and after for loop are getting executed and but console logs inside for loop are not getting executed.

And therefore, the newTaskList array remains empty [] and requiredTaskLists gets set to an empty array too []. Hence, requiredTaskLists.length always equals to 0.

And hence my code for displaying list is not rendering at all. It is always the <TaskListAbsent /> component which is rendering.

Please help me with this. Tell me where I am wrong. And is there is another way to achieve what I am trying to achieve?

TYPO3 v12 Backend Mixed Content Error loading Javascript Libs

We have setup TYPO3 behind a TRAEFIK Reverse Proxy. Yesterday everything looks good, but today our Backend is empty. In the Browser Console we found

“Mixed Content: The page at ” was loaded over HTTPS, but
requested an insecure script ”. This request has been blocked;
the content must be served over HTTPS.”

And after that the following errors:

‘TypeError: Failed to fetch dynamically imported module:
https://xxx.xxx.de/typo3/sysext/backend/Resources/Public/JavaScript/live-search/result-types/page-result-type.js?bust=c8eb9eafbb5af2f5c1b1dbbd651572846060258b’

Why is TYPO3 is trying to load a Script with an insecure URL?

Our Website seems to be good. But Login into Backend ends up with the left Menu und a white Screen:

I want to divide childrens by their props. but the result value of console.log is different by using “use client”

I want to divide childrens by their props.

for example, if children has classname “ABC”, It is not displayed.

Not using “use client”,

enter image description here

type is “div” and show up everything well

But using “use clinet”,

enter image description here

type is like Function. and show up anything..

const TabPanel = ({ value, children }) => { return <div data-tabpanel-value={value}>{children}</div>; };

this is my simple code.

Even if i use “use client”, how to get type “div” like not using “use client”?

  1. using createElement << is failed
  2. using “use server” << is too many error and not work!
  3. ReactDOM.render() << is not work!

Need to know jest dom setup in plain vanilla javascript

i created an todo app in vanilla javascript now i needed to test that using jest but the thing jest-environment is not working on that. i need proper procedure to setup get done

package.json
`{
“name”: “todo-list-e2”,
“version”: “1.0.0”,
“description”: “primary-violet:7743DB;r primary-white:F7EFE5r secondary-white:FFFBF5r primary-yellow:ffc100”,
“main”: “index.js”,
“scripts”: {
“test”: “jest –watch”,
“coverage”: “jest –coverage”
},

“keywords”: [],
“author”: “”,
“license”: “ISC”,
“devDependencies”: {
“@testing-library/jest-dom”: “^6.4.6”,
“jest”: “^29.7.0”,
“jest-environment-jsdom”: “^29.7.0”,
“jsdom”: “^24.1.0”
}
}jest.config,jsmodule.exports = {
testEnvironment: “jsdom”,

};`

Todo list using array and loop

I want to create a todo list using array and loop and display the list in div container. I am able to display the list but it is muliplying the same list stored and is displayed.

<body>
    <p class="title"> Todo List </p>
    <input type="text" class="js-input-todo" placeholder="Todo name">
    <button type="submit" class="js-btn-todo" onclick="handleAddTodo()">Add</button>

    <div class="todo-list"></div>

 <script src="script/11-arrays-loop.js"></script>
</body>

//script 

let names = []

let todoListHTML = ''

function handleAddTodo(){
  const todo_input = document.querySelector('.js-input-todo');
  const todoValue = todo_input.value
  const result = document.querySelector('.todo-list');
 
  names.push(todoValue);
  for(let i = 0; i <  names.length ; i++){
   let todoName = names[i]
   const html = `<p>${todoName} </p>`
   todoListHTML = html;
   result.innerHTML +=todoListHTML;
   
   todo_input.value = '';
  }
  
  

}

I want to the array value to not repeat and displayed in the output