How to list all members with a specific role with discord.js?

I try to make a simple bot that just lists all members that have a specific role.

I went through most of the similar questions I could find, but their answers seem outdated. So I tried this but end up with the result ‘undefined’, although the role exists.

const discord = require('discord.js');
const { Client, Intents } = require('discord.js');
const client = new discord.Client(
    { intents: [
        Intents.FLAGS.GUILDS, 
        Intents.FLAGS.GUILD_MESSAGES,
        Intents.FLAGS.GUILD_MEMBERS
    ] });


const prefix ="!";
const MemberID = "912852591023628371";

client.on('ready', () => {
    console.log('Connected to the bot');

  

});

client.on('messageCreate', msg => {
    if (msg.content === 'hi') {
        msg.reply('Hi to you too!');
    }
  
});

client.on('messageCreate', async message => {
    if (message.content === prefix + 'list') {
        let list = client.guilds.cache.get(MemberID);
        console.log(list);
        }
    }
);

MATLAB to Javascript Code Conversion Issue

Suppose I have the following MATLAB code:

function xn=normalize(x)
xn=x/norm(x);
end

nTriangles=size(faces,1); 
    
trN=zeros(nTriangles,3);
for i=1:nTriangles
    trN(i,:)=normalize(cross(vert(faces(i,2),:)-vert(faces(i,1),:),...vert(faces(i,3),:)-vert(faces(i,1),:)));
end

I want to convert it to JavaScript using the math.js libraries.

I tried doing the following:

const math = require('mathjs')

function normalize(x){
return x/math.norm(x);}
    
let nTriangles = math.size(faces)[0];
let trNormals=math.zeros(nTriangles,3);
    for (let i = 0; i < nTriangles; i++) {
    let trN=math.row(trNormals,i);
    trN = normalize(math.cross(math.row(vert,math.subset(faces,math.index(i,1)))-math.row(vert,math.subset(faces,math.index(i,0))),... math.row(vert,math.subset(faces,math.index(i,2)))-math.row(vert,math.subset(faces,math.index(i,0)))));

However,this is wrong. I get an error:

Argument type number is not assignable to parameter type MathArray | Matrix

I keep trying to resolve the error, but to no success.
Can someone suggest how I can go about solving the issue or how I could else write the MATLAB code into JS?

On another note, the MATLAB code uses ,… while in Javascript this doesn’t seem to work.

jquery datatables issue on asp.net core 5

i followed all the steps to add jquery table but showing proccessing error

jquery datatables issue on asp.net core 5 i downlaod datatable and added the file and the same code work for another example

DataTables show Ajax error and not loaded the data

conroller code

    public IActionResult IndexGrid()
    {
        return View();
    }
    [HttpPost]

    public async Task<IActionResult> load()
    {
        var students = from s in _context.Students
                       select s;

        return Json(await students.ToListAsync());
    }

view code

<link href="~/lib/datatables/css/dataTables.bootstrap4.css" rel="stylesheet" />
<div class="container">
    <h3 class="text-primary">Customers</h3>
    <hr />

    <table id="Customers" class="table table-striped table-bordered dt-responsive nowrap">
        <thead>
            <tr>
                <th>Id</th>
                <th>LastName</th>
                <th>FirstMidName</th>
                <th>EnrollmentDate</th>
                
            </tr>
        </thead>
    </table>
</div>

@section Scripts
{
    <script src="~/lib/datatables/js/jquery.dataTables.js"></script>
    <script src="~/lib/datatables/js/dataTables.bootstrap4.js"></script>
    <script src="~/js/customersDatatable.js"></script>
}

custom js file

 $(document).ready(function () {
        $('#Customers').dataTable({
            "processing": true,
            "serverSide": true,
            "filter": true,
            "ajax": {
                "url": "/home/load",
                "type": "POST",
                "datatype": "json"
            },
            "columnDefs": [{
                "targets": [0],
                "visible": false,
                "searchable": false
            }],
            "columns": [
                { "data": "Id", "name": "Id", "autowidth": true },
                { "data": "FirstMidName", "name": "FirstMidName", "autowidth": true },
                { "data": "LastName", "name": "LastName", "autowidth": true },
                { "data": "EnrollmentDate", "name": "EnrollmentDate", "autowidth": true },
            
                {
                    "render": function (data, type, row) { return '<a href="#" class="btn btn-danger" onclick=DeleteCustomer("' + row.id + '"); > Delete </a>' },
                    "orderable": false
                },
    
            ]
        });
    });

Passing parameters in wireframe

I need your help. I am creating a wireframe; I have a table like the one shown in the code below.

I want to pass the parameters of the table (so item.id and item.n_a) present in the divA inside the divB.

The table is a dynamic table.

Can anyone kindly help me to do this?

.
.
.
xmlhttp.onreadystatechange = function () {
            if (this.readyState == 4 && this.status == 200) {
                var myArr = JSON.parse(this.responseText);
                var results = {};
                for (var i = 0, len = myArr.Items.length; i < len; i++) {
                    var id_art = myArr.Items[i].id_a;
                    if (id_art == id_url) {
                        results[i] = myArr.Items[i];
                    }
                }
Object.entries(results).forEach(item => {
  item = item[1];
  let child = document.createElement("tr");
  child.innerHTML = `
<td>${item.id}</td>
<td><${item.n_a}</td>`;
  table.appendChild(child);
  document.querySelector('#my-table').appendChild(child);
})

Puppeteer action based on Javascript filter parent array based on child value

I haven an array containing a child array containing a label some div’s and a button.

MY goal is to click the button within the main <div.phoneinformation> only when the label is equal to “IOS”.
I have read this post, but I could not make it work.
All help is appreciated.

const list =[
{
 <div.phoneinformation>,
  ["<label>IOS</label>",
   "<div.version></div>",
   "<div.production-year></div>",
   "<div.info></div>",
   "<button></button>"],
 },
 {
 <div.phoneinformation>,
  ["<label>ANDROID</label>",
   "<div.version></div>",
   "<div.production-year></div>",
   "<div.info></div>",
   "<button></button>"],
 },
 {
 <div.phoneinformation>,
  ["<label>ANDROID</label>",
   "<div.version></div>",
   "<div.production-year></div>",
   "<div.info></div>",
   "<button></button>"],
 },
 {
 <div.phoneinformation>,
  ["<label>IOS</label>",
   "<div.version></div>",
   "<div.production-year></div>",
   "<div.info></div>",
   "<button></button>"],
 },
 {
 <div.phoneinformation>,
  ["<label>GOOGLE</label>",
   "<div.version></div>",
   "<div.production-year></div>",
   "<div.info></div>",
   "<button></button>"],
 },
 {
 <div.phoneinformation>,
  ["<label>IOS</label>",
   "<div.version></div>",
   "<div.production-year></div>",
   "<div.info></div>",
   "<button></button>"],
 },
 
  
]

Replace word not in quotes

I’m looking to replace a word that’s not in quotes, whether single or double, accounting for escapes as well.

My test case:

Trying to replace

obj1 = {
  name: person,
  favoriteQuote: "I am my own person.",
}

person with "Joe".

Expected result:

obj1 = {
  name: "Joe",
  favoriteQuote: "I am my own person.",
}

I saw this question: Match and replace a word not in quotes (string contains escaped quotes) which I thought was similar and could be a good starting point the accepted answer does not work at all:

https://regex101.com/r/Lfan64/2

What’s a regex that could do this? Thanks.

Loading another html page (and all its scripts) into another page

We have a large html page, say A.html that takes various parameters and load data accordingly. Assume it is something like https://{mydomain}/{longpath}/A.html?someparam=large_string

It is on a static aws website with cloudfrount. I want to create another page say B.html that is at a url that looks more user friendly and has parameters as part of path. say https://{mydomain}/shortstring

This page or a lambda edge function that generates this page will decipher the path url and load the original page with right values set. We don’t want to return the large html page A.html on every access to this path in the expectation that loading of A.html can be better done from cache instead of losing the cache advantage at every shortstring url.

Is there a way to load A.html inside the B.html in such a way that the user only sees the user friendly urls in address bar ie https://{mydomain}/shortstring .

PS: Note this is different from redirecting to https://{mydomain}/{longpath}/A.html?someparam=large_string

Thanks in advance

Javascript if, else, else if, logical operators problem

Why is that not working?

So, I have a problem with my javascript code and i don’t know why my code isn’t working.
Maybe i don’t see a problem. I need a help.
I’ve tried everything, i don’t know why my code isn’t working :/

var oktet1 = 192;
var oktet2 = 256;
var oktet3 = 256;
var oktet4 = 256;

if(((oktet2 || oktet3 || oktet4) <= 255) || ((oktet2 || oktet3 || oktet4) >= 0)) {
    if((oktet1 >= 0) || (oktet1 <= 127)) {
        console.log("Adres ipv4: ");
        console.log(oktet1 + "." + oktet2 + "." + oktet3 + "." + oktet4);
        console.log("Klasa adresu: A");
        console.log("Maska sieci: 255.0.0.0");
    } else if((oktet1 > 127) || (oktet1 <= 191)) {
        console.log("Adres ipv4: ");
        console.log(oktet1 + "." + oktet2 + "." + oktet3 + "." + oktet4);
        console.log("Klasa adresu: B");
        console.log("Maska sieci: 255.255.0.0");
    } else if((oktet1 > 191) || (oktet1 <= 223)) {
        console.log("Adres ipv4: ");
        console.log(oktet1 + "." + oktet2 + "." + oktet3 + "." + oktet4);
        console.log("Klasa adresu: C");
        console.log("Maska sieci: 255.255.255.0");
    } else if((oktet1 > 223) || (oktet1 <= 239)) {
        console.log("Adres ipv4: ");
        console.log(oktet1 + "." + oktet2 + "." + oktet3 + "." + oktet4);
        console.log("Klasa adresu: D");
    } else if((oktet1 > 239) || (oktet1 <= 255)) {
        console.log("Adres ipv4: ");
        console.log(oktet1 + "." + oktet2 + "." + oktet3 + "." + oktet4);
        console.log("Klasa adresu: E");
    } else if(((oktet1 || oktet2 || oktet3 || oktet4) >= 255) || ((oktet1 || oktet2 || oktet3 || oktet4) <= 0)) {
        console.log("Nieprawidłowy adres. Podaj adres w zakresie od 0 do 255!");
    }
} else {
    console.log("Podaj prawidlowy adres ip w przedziale od 0 do 255");
}

Could not resolve all artifacts for configuration ‘:classpath’. Windows 10 2022 RN V 0.67

I installed react native version 0.67, following all the steps of the development environment setup at https://reactnative.dev/docs/environment-setup (So environment variables are fine). I am currently using windows 10 and I am using node LTS version 16.13.2 and java version 11. I have Android Studio Bumblebee and so far everything seems to be working fine when I use npx react-native start
to initialize metro. The problems come when I run npx react-native run-android

I’ll show the errors I get:

$ npx react-native run-android

info Running jetifier to migrate libraries to AndroidX. You can disable it using
 "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reus
ed, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'IntentoXXVI'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not download kotlin-reflect-1.4.31.jar (org.jetbrains.kotlin:kotlin-r
eflect:1.4.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrai
ns/kotlin/kotlin-reflect/1.4.31/kotlin-reflect-1.4.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kot
lin/kotlin-reflect/1.4.31/kotlin-reflect-1.4.31.jar'.
            > Permission denied: connect
   > Could not download kotlin-stdlib-jdk7-1.4.31.jar (org.jetbrains.kotlin:kotl
in-stdlib-jdk7:1.4.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrai
ns/kotlin/kotlin-stdlib-jdk7/1.4.31/kotlin-stdlib-jdk7-1.4.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kot
lin/kotlin-stdlib-jdk7/1.4.31/kotlin-stdlib-jdk7-1.4.31.jar'.
            > Permission denied: connect
   > Could not download kotlin-stdlib-1.4.31.jar (org.jetbrains.kotlin:kotlin-st
dlib:1.4.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrai
ns/kotlin/kotlin-stdlib/1.4.31/kotlin-stdlib-1.4.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kot
lin/kotlin-stdlib/1.4.31/kotlin-stdlib-1.4.31.jar'.
            > Permission denied: connect
   > Could not download proguard-base-6.0.3.jar (net.sf.proguard:proguard-base:6
.0.3)
      > Could not get resource 'https://repo.maven.apache.org/maven2/net/sf/prog
uard/proguard-base/6.0.3/proguard-base-6.0.3.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/net/sf/proguard/p
roguard-base/6.0.3/proguard-base-6.0.3.jar'.
            > Permission denied: connect
   > Could not download error_prone_annotations-2.3.2.jar (com.google.errorprone
:error_prone_annotations:2.3.2)
      > Could not get resource 'https://repo.maven.apache.org/maven2/com/google/
errorprone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/com/google/errorp
rone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2.jar'.
            > Permission denied: connect
   > Could not download commons-compress-1.12.jar (org.apache.commons:commons-co
mpress:1.12)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/apache/
commons/commons-compress/1.12/commons-compress-1.12.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/apache/common
s/commons-compress/1.12/commons-compress-1.12.jar'.
            > Permission denied: connect
   > Could not download animal-sniffer-annotations-1.18.jar (org.codehaus.mojo:a
nimal-sniffer-annotations:1.18)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/codehau
s/mojo/animal-sniffer-annotations/1.18/animal-sniffer-annotations-1.18.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/codehaus/mojo
/animal-sniffer-annotations/1.18/animal-sniffer-annotations-1.18.jar'.
            > Permission denied: connect
   > Could not download kotlin-stdlib-common-1.4.31.jar (org.jetbrains.kotlin:ko
tlin-stdlib-common:1.4.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrai
ns/kotlin/kotlin-stdlib-common/1.4.31/kotlin-stdlib-common-1.4.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kot
lin/kotlin-stdlib-common/1.4.31/kotlin-stdlib-common-1.4.31.jar'.
            > Permission denied: connect

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 42s

error Failed to install the app. Make sure you have the Android development envi
ronment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8
081

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'IntentoXXVI'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not download kotlin-reflect-1.4.31.jar (org.jetbrains.kotlin:kotlin-r
eflect:1.4.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrai
ns/kotlin/kotlin-reflect/1.4.31/kotlin-reflect-1.4.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kot
lin/kotlin-reflect/1.4.31/kotlin-reflect-1.4.31.jar'.
            > Permission denied: connect
   > Could not download kotlin-stdlib-jdk7-1.4.31.jar (org.jetbrains.kotlin:kotl
in-stdlib-jdk7:1.4.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrai
ns/kotlin/kotlin-stdlib-jdk7/1.4.31/kotlin-stdlib-jdk7-1.4.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kot
lin/kotlin-stdlib-jdk7/1.4.31/kotlin-stdlib-jdk7-1.4.31.jar'.
            > Permission denied: connect
   > Could not download kotlin-stdlib-1.4.31.jar (org.jetbrains.kotlin:kotlin-st
dlib:1.4.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrai
ns/kotlin/kotlin-stdlib/1.4.31/kotlin-stdlib-1.4.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kot
lin/kotlin-stdlib/1.4.31/kotlin-stdlib-1.4.31.jar'.
            > Permission denied: connect
   > Could not download proguard-base-6.0.3.jar (net.sf.proguard:proguard-base:6
.0.3)
      > Could not get resource 'https://repo.maven.apache.org/maven2/net/sf/prog
uard/proguard-base/6.0.3/proguard-base-6.0.3.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/net/sf/proguard/p
roguard-base/6.0.3/proguard-base-6.0.3.jar'.
            > Permission denied: connect
   > Could not download error_prone_annotations-2.3.2.jar (com.google.errorprone
:error_prone_annotations:2.3.2)
      > Could not get resource 'https://repo.maven.apache.org/maven2/com/google/
errorprone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/com/google/errorp
rone/error_prone_annotations/2.3.2/error_prone_annotations-2.3.2.jar'.
            > Permission denied: connect
   > Could not download commons-compress-1.12.jar (org.apache.commons:commons-co
mpress:1.12)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/apache/
commons/commons-compress/1.12/commons-compress-1.12.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/apache/common
s/commons-compress/1.12/commons-compress-1.12.jar'.
            > Permission denied: connect
   > Could not download animal-sniffer-annotations-1.18.jar (org.codehaus.mojo:a
nimal-sniffer-annotations:1.18)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/codehau
s/mojo/animal-sniffer-annotations/1.18/animal-sniffer-annotations-1.18.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/codehaus/mojo
/animal-sniffer-annotations/1.18/animal-sniffer-annotations-1.18.jar'.
            > Permission denied: connect
   > Could not download kotlin-stdlib-common-1.4.31.jar (org.jetbrains.kotlin:ko
tlin-stdlib-common:1.4.31)
      > Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrai
ns/kotlin/kotlin-stdlib-common/1.4.31/kotlin-stdlib-common-1.4.31.jar'.
         > Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kot
lin/kotlin-stdlib-common/1.4.31/kotlin-stdlib-common-1.4.31.jar'.
            > Permission denied: connect

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 42s

    at makeError (C:UsersOrlando.ORLANDOCS1DesktopIntentoXXVInode_modules@
react-native-communitycli-platform-androidnode_modulesexecaindex.js:174:9)
    at C:UsersOrlando.ORLANDOCS1DesktopIntentoXXVInode_modules@react-nativ
e-communitycli-platform-androidnode_modulesexecaindex.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (C:UsersOrlando.ORLANDOCS1DesktopIntentoXXVIno
de_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroi
drunOnAllDevices.js:109:5)
    at async Command.handleAction (C:UsersOrlando.ORLANDOCS1DesktopIntentoXX
[email protected]:192:9)
info Run CLI with --verbose flag for more details.

Clearly there are too many errors but the source of the problems (in my opinion) comes from the fact that the :classpath cannot be configured and other problems regarding gradle. I have not been able to solve it because similar questions have been asked in years like 2019 or 2018 and I have tried those solutions but they have not worked for me. I think it is because I am using more recent versions and I don’t know if that can cause problems, but these tools are the ones that are required of me, then I will show the gradle dependencies:

gradle.properties

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.99.0

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

I will be truly grateful for your answers, I have WEEKS stuck in this problem and I can’t find what else to do

How do I create a .js file that creates a navigation bar in html

Ok so, I am creating this site and I want every page to have a navigation bar, how do I make it so that instead of having to write the html for the navigation bar on every page, I just write in the .js file and add this javascript file to every page.

Btw, I’m not asking how to write a navigation bar in html, I’ve already done that.

Submit HTML Form to database without redirecting page?

I have been trying this for some time now and tested multiple solutions, but dont seem to find the correct one. I have a HTML form i want submitted to the database, without redirecting the page. Right now the data gets sent to the database when submitted, but the page redirects to insert.php

Im kinda new to coding and havnt coded for atleast 2 years. I saw alot of the solutions included AJAX, but i dont know where to put the AJAX code.

index.html

<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script type="text/javascript" src="assets/js/app.js"></script>
    <link rel="stylesheet" href="assets/css/main.css">
</head>

<body>
    <div id="submitFail" class="alert-fail">
        <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
        Please fill all the fields!
    </div>
    <div id="submitSuccess" class="alert-success">
        <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
        The giveaway is now successfully submitted!
    </div>
    <form action="insert.php" method="post" onsubmit="submitInfo();">
        <section>
            <label for="category">Choose category</label>
            <select id="category" name="category">
                <option value="csgo">CS:GO</option>
                <option value="rust">RUST</option>
                <option value="crypto">CRYPTO</option>
                <option value="dota">DOTA</option>
                <option value="tf2">TF2</option>
                <option value="giftcards">GIFTCARDS</option>
                <option value="other">OTHER</option>
            </select>
        </section>
        <label for="title">Title</label>
        <input type="text" id="title" name="title"><br><br>
        <label for="type">Type</label>
        <input type="text" id="type" name="type"><br><br>
        <label for="value">Value</label>
        <input type="number" id="value" name="value"><br><br>
        <label for="image">Image (URL)</label>
        <input type="url" id="image" name="image"><br><br>
        <label for="time">Ends (In Hours)</label>
        <input type="number" id="time" name="time"><br><br>
        <label for="link">Link to the giveaway</label>
        <input type="url" id="link" name="link"><br><br>
        <input type="checkbox" id="giveawayRules" name="checkbox" value="scam-ok">
        <label for="checkbox-scam"> I have read and agree to the giveaway rules.</label><br>
        <input type="submit" value="Submit">
    </form>
</body>

insert.php

<?php

// servername => localhost
// username => root
// password => empty
// database name => steamaways

$conn = mysqli_connect("localhost", "root", "", "steamaways");
    
// Check connection
if($conn === false){
    die("ERROR: Could not connect. " 
        . mysqli_connect_error());
}
    
// Taking all 8 values from the form data(input)
$category =  $_REQUEST['category'];
$title = $_REQUEST['title'];
$type =  $_REQUEST['type'];
$value = $_REQUEST['value'];
$image = $_REQUEST['image'];
$time = $_REQUEST['time'];
$link = $_REQUEST['link'];

    
// Performing insert query execution
// here our table name is college
$sql = "INSERT INTO giveaways (category, title, giveaway_type, giveaway_value, giveaway_image, giveaway_time, link)
        VALUES ('$category','$title','$type','$value','$image','$time','$link')";  


if(mysqli_query($conn, $sql)){
    echo nl2br("n$categoryn $titlen "
        . "$typen $valuen $imagen $timen $link");
} else{
    mysqli_error($conn);
}

// Close connection
mysqli_close($conn);
?> 

app.js

function submitInfo() {
    var submitSuccess = document.getElementById("submitSuccess");
    var submitFail = document.getElementById("submitFail");
    var giveawayRules = document.getElementById('giveawayRules');
    var giveawayTitle = document.getElementById('title');
    var giveawayType = document.getElementById('type');
    var giveawayValue = document.getElementById('value');
    var giveawayImage = document.getElementById('image');
    var giveawayTime = document.getElementById('time');
    var giveawayLink = document.getElementById('link');

    if  (giveawayRules.checked === false || giveawayTitle.value == '' || giveawayType.value == '' || giveawayValue.value == '' || giveawayImage.value == '' || giveawayTime.value == '' ||  giveawayLink.value == '') {
        submitFail.style.display="block";
        $("#submitFail").delay(5000).fadeOut(750);
        submitSuccess.style.display="none";
    } else {
        submitSuccess.style.display="block";
        $("#submitSuccess").delay(5000).fadeOut(750);
        submitFail.style.display="none";
    }
}

Argument of type ‘string’ is not assignable to parameter of type ‘Date’

I am new at angular and dont quite know where I’m going wrong with respect to dates. I am getting the error : “Argument of type ‘string’ is not assignable to parameter of type ‘Date’. <button mat-raised-button type=”button” (click)=”createDamageAssessmentReport(DescOfReportInput.value, AuthorInput.value, DateInput.value)” color=”primary”>Create”

<mat-sidenav-content>
    <div class="sect">
        <h1>Damage Assessment Report</h1>
    </div>
    <mat-card>
        <mat-card-header>Create report:</mat-card-header>
        <br><br>
        <mat-card-content>
            <div> 
                <mat-form-field>
                    <mat-label>Report Description</mat-label>
                    <input
                        #DescOfReportInput  
                        placeholder="Description of Report"
                        matInput type= "string"
                        required>
                </mat-form-field>
                    <br>
                <mat-form-field>
                    <mat-label>Author</mat-label>
                    <input  
                        #AuthorInput
                        placeholder="Author"
                        matInput type= "string"
                        required>
                </mat-form-field>
                <br>
                <mat-form-field>
                <mat-label>Date</mat-label>
                <input  
                        #DateInput
                        placeholder="----/--/--"
                        matInput type= "Date"
                        required>
                </mat-form-field>
                <br>
            </div>
            <div> 
                <button mat-raised-button type="button" (click)="createDamageAssessmentReport(DescOfReportInput.value, AuthorInput.value, DateInput.value)" color="primary">Create</button>
            </div>
        </mat-card-content>
    </mat-card>
</mat-sidenav-content>

The associated typescript file is as follows:

import { Component, OnInit } from '@angular/core';
import { DamageAssessmentReportService } from 'src/app/damage-assessment-report.service';

@Component({
  selector: 'app-fa-daform',
  templateUrl: './fa-daform.component.html',
  styleUrls: ['./fa-daform.component.css']
})
export class FADAFormComponent implements OnInit {

    constructor(private damageAssessmentReportService : DamageAssessmentReportService) { }
  
    //assessmentDescription: string, author: string, reportDateTime: Date
  
    createDamageAssessmentReport(assessmentDescription: string, author: string, reportDateTime: Date){
        this.damageAssessmentReportService
            .createDAReport("New Report","Name", new Date(2020, 9, 10))
            .subscribe((response : any)=>{
                console.log(response);
            });
    }

    ngOnInit(): void { }
}    

Modal Save Button Doesn’t Work (Bootstrap 5)

I am following this guide (https://softdevpractice.com/blog/asp-net-core-mvc-ajax-modals/), and cannot get the save button on my modal to work. I tried putting it within the form tag but then it was using the form action from the parent view not the partial.

At first I could not get the close buttons to work but that was resolved by changing data-dismiss to data-bs-dismiss. I am wondering if I need to do similarly for save, since things have changed with Bootstrap 5.

My code is as follows:

Parent View

<div id="AddStudyModal"></div>
// Irrelevant stuff here
<div>
   <button type="button" class="btn btn-secondary" data-toggle="ajax-modal" data-bs-target="#add-study" data-url="@Url.Action("AddStudy", "App", new {id = Model.GUID})">Add</button>
</div>

Partial View

<div class="modal fade" id="add-study" tabindex="-1" role="dialog" aria-labelledby="addStudyLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="addStudyLabel">Add Study</h5>
                <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form asp-controller="App" asp-action="AddParticipant" method="post">
                    @Html.HiddenFor(m => m.ParticipantGuid)
                    <div asp-validation-summary="ModelOnly"></div>
                    <div class="mb-3 form-group">
                        <label asp-for="Studies" class="form-label"></label>
                        <select asp-for="SelectedStudyGuid" asp-items="Model.Studies" class="form-control" autocomplete="off">
                            <option value=""> Select a Study</option>
                        </select>
                        <span asp-validation-for="SelectedStudyGuid" class="text-danger"></span>
                    </div>
                    <div class="mb-3 form-group">
                        <label asp-for="StartDate" class="form-label"></label>
                        <input asp-for="StartDate" class="form-control" autocomplete="off"/>
                        <span asp-validation-for="StartDate" class="text-danger"></span>
                    </div>
                    <div class="mb-3 form-group">
                        <label asp-for="EndDate" class="form-label"></label>
                        <input asp-for="EndDate" class="form-control" autocomplete="off"/>
                        <span asp-validation-for="EndDate" class="text-danger"></span>
                    </div>
                    <div class="text-center">
                    </div>
                    <div class="text-center">@ViewBag.Message</div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" data-save="modal">Save</button>
            </div>
        </div>
    </div>
</div>

site.js

$(function (){
    var AddStudyElement = $('#AddStudyModal');
    $('button[data-toggle="ajax-modal"]').click(function(event){
        var url = $(this).data('url');
        $.get(url).done(function(data){
            AddStudyElement.html(data);
            AddStudyElement.find('.modal').modal('show');
        })
    })

    AddStudyElement.on('click', '[data-save="modal"]', function(event){
        event.preventDefault();

        var form = $(this).parents('.modal').find('form');
        var actionUrl = form.attr('action');
        var sendData = form.serialize();

        $.post(actionUrl, sendData).done(function(data){
            AddStudyElement.find('modal').modal('hide');
        })
    })
})

use JavaScript to press enter key to trigger pre-defined events

I need to use JavaScript to update some data in a input field, and then programmatically to simulate a “Enter” keypress in order to fire up some events of that field to validate data.

Note that I didn’t develop the site. I just do some add-on script for some customization. Therefore, I don’t know what exact events attached to that field, or to be fired. All I know is if I do it manually, after key in item# and press enter, it will do something for validation.

I searched result here before.
I have tried following 3 methods and all failed.

Any more ideas on how to solve?

#1:

const kexx = new KeyboardEvent('keypress', {
    bubbles: true, cancelable: true, keyCode: 13
});
    
inputEle.dispatchEvent(kexx);

#2:

    var exx = jQuery.Event("keypress");
    exx.which = 13; //choose the one you want
    exx.keyCode = 13;

$(inputEle).trigger(exx);

#3:

$(inputEle).val(itemnbrInputAry[i]).trigger('keyup');