Asp razor form not submitting on popup modal button click

I am using JavaScript to submit the popup dialog, but it’s not submitting.

here is my view, I have checked the javascript, it is firing up but the $(“form”).submit() statement is not doing anything and the next statement is executed.

@{ 
    ViewBag.Title = "Add Comment";
    Layout = "~/Views/Shared/Popup.cshtml"; 
}

<script type="text/javascript">
    $(document).ready(function () {
        $("#SaveComment").click(function (e) {
            e.preventDefault();
            $("#form").submit();
            parent.HidePopup(true);
        });
    });
    </script>

@using (Html.BeginForm("CreateComment", "OnlineInventory", FormMethod.Post, new { id = "form"}))
{
    @Html.Hidden("OccupantInventoryRoomId", Model.OccupantInventoryRoomId)
    @Html.Hidden("OccupantInventoryItemId", Model.OccupantInventoryItemId)
    @Html.HiddenFor(m => m.AllocationId)
    @Html.HiddenFor(m => m.Status)

    @Html.TextAreaFor(m => m.Comment, new { Class="CommentTextBox" })
    <div class="Navigation">
        <input type="button" value="Cancel" onclick="parent.HidePopup(false)" />
        <input id="SaveComment" type="button" value="Save" class="InputButton"/>
    </div>
}

this is my controller

  public class OnlineInventoryController : Controller
    {
        [HttpPost]
        public ActionResult CreateComment(AddNewCommentModel model, int? allocationId)
        {
            User user = this.userProvider.GetByUserName(System.Web.HttpContext.Current.User.Identity.Name);

            if (!this.userProvider.IsAllowed(9, user.KxId))
            {
                return this.RedirectToAction("Index", "Inspections");
            }

            try
            {
                OccupantInventoryComment commentToSave = new OccupantInventoryComment
                {
                    Comment = model.Comment,
                    CommentDateTime = DateTime.Now,
                    CreatedByUserId = user.KxId,
                    OccupantInventoryRoomId = model.OccupantInventoryRoomId,
                    OccupantInventoryItemId = model.OccupantInventoryItemId,
                };
                ViewBag.OccupantInventoryRoomId = model.OccupantInventoryRoomId;
                ViewBag.OccupantInventoryItemId = model.OccupantInventoryItemId;
                this.occupantInventoryCommentProvider.Save(commentToSave);
            }
            catch (Exception ex)
            {
                this._audit.Add(Product.KxRoomCheckerBackOffice, Severity.Error, ActivityType.Create, new StackTrace().GetFrame(0).GetMethod().Name, string.Empty, string.Empty, ex);
            }

            return this.RedirectToAction(model.Status.ToString(), new InventoryModel { AllocationId = model.AllocationId, Updated = true });
        }
}

html form not grabbing correct variables from survey

I am building a survey form that gathers information from students, using HTML (open to using javascript too) and have found several examples online but none seem to be working. The survey form is currently just selecting these:

enter image description here

The survey should be selecting all options (first name, last name, living place, college choices, major, campus visit), and I don’t know how to fix this.

This is the survey and the code:

enter image description here

 <h3> Senior Survey </h3>
    <div class="w3-container">

      <script type="text/javascript">
        console.log("Prospective student form is about to be displayed.");
      </script>

      <form method="post" action="mailto:[email protected]" method="GET" enctype="text/plain" name="seniorsurvey">
        <table class="w3-table w3-blue" id="second-gradient">
          
          <tr>
            <td style="text-align: center";> 
            <p><b> Please enter your first and last names. </b></p>
            <input type="text" id="firstname" maxlength="60" placeholder="First Name:"/> 
            <input type="text" id="lastname" maxlength="60" placeholder="Last Name:"/>  
            </td>
          </tr>

          <tr>
            <td style="text-align: center";> 
              <p><b> Where do you live? </b></p>
              <input type="radio" id="peru" name="radiobutton" value="Peru">
              <label for="peru">Peru</label>

              <input type="radio" id="southamerica" name="radiobutton" value="SA">
              <label for="southamerica">South America</label>

              <input type="radio" id="unitedstates" name="radiobutton" value="USA">
              <label for="unitedstates">United States</label> 
            </td>
          </tr>

          <tr>
            <td>
              <fieldset style="text-align: center";>
                <p><b> What were your other top college choices? </b></p>
                <input type="checkbox" id="bentley" name="uni">
                <label for="bentley">Bentley U.</label>

                <input type="checkbox" id="brandeis" name="uni">
                <label for="brandeis">Brandeis U.</label>
                
                <input type="checkbox" id="boston" name="uni">
                <label for="boston">Boston U.</label>
                
                <input type="checkbox" id="babson" name="uni">
                <label for="babson">Babson U.</label>     
                
                <input type="checkbox" id="northeastern" name="uni">
                <label for="northeastern">Northeastern U.</label>               
              </fieldset>
            </td>
          </tr>

          <tr>
            <td style="text-align: center";> 
              <p><b> What is your prospective major? </b></p>
              <select name="majors" id="majors">
                <option value="un">undecided</option>
                <option value="cis">Computer Information Systems</option>
                <option value="fi">Finance</option>
                <option value="acc">Accounting</option>
                <option value="ci">Creative Industries</option>
                <option value="mkt">Marketing</option>
              </select>
              <br>
            </td>
          </tr>

          <tr>
            <td style="text-align: center";> 
              <p><b> When do you plan to visit campus? </b></p>
              <input type="date" id="start" name="visit-start" value="2021-10-25" min="2021-10-25" max="2030-12-31">
              <br><br>
            </td>
          </tr>

          <tr>
            <td style="text-align: center";> 
              <button type="submit" value="Submit College Info"> Submit </button>
              <button type="reset" value="Clear College Info"> Clear  </button>
              <br><br>
            </td>
          </tr>

        </table>
      </form>      

    </div>

Promise trouble! How can I write this in such a way that it waits for the end?

Trying to write this in a way that it will wait for the db operations to complete. Possible?

function addFriendsToSession(session, sessionId) {
    const friends = [];

    const incoming = session.users.forEach(async user => {
        console.log('user', user);
        await db
            .collection('users/' + user + '/settings')
            .doc(user)
            .get()
            .then(doc => {
                if (doc.exists) {
                    const returnObj = doc.data();
                    return returnObj.friends ? returnObj.friends : [];
                } else {
                    return [];
                }
            });
    });
    friends.push(incoming);
    return friends;
}

array elements does not match same assigned elements

I wrote a function where I am looping through an array(which contains a number of array elements itself).
e.g. theMainAr:[ [ 5 ],[ 5, 3 ],[ 5, 3, 9 ],[ 5, 3, 9, 4 ],[ 3 ],[ 3, 9 ],[ 3, 9, 4 ],[ 9 ],[ 9, 4 ],[ 4 ] ]
The main array I got the above array from is : weights: [5,3,9,4]
I want to get a combination from these above arrays like this:sameLenAr:[[5,9],[5,4],[5,3,4],[3,4]]
My code is:

let sameLenAr = []
    let inc = 0
    for(let i=1;i<theMainAr.length-3;i++){  
        let curLen = theMainAr[i].length
        if(curLen>1){
            let curAr = theMainAr[i]
            let curArLen = curAr.length
            let indexOfEle = weights.indexOf(curAr[curLen-1])
              for(let m=indexOfEle+1; m<lenOfWets;m++){
                //   console.log(a)
                 curAr[curArLen -1] = weights[m]
                 console.log(curAr)
                 sameLenAr[inc] = curAr
                 inc++
                }
        }
    }

But Everytime I get an output like this: [[5,4],[5,4],[5,3,4],[3,4]]
The first element is not [5,9]
Why?

sqlMessage: “Unknown column ‘c.created’ in ‘field list'”

Im getting this error which I’m not completely sure how to solve.

    CommentModel.getCommentsForPost = (postId) => {
    let baseSQL = `SELECT u.username, c.comment, c.created, c.id
    FROM comments c
    JOIN users u
    on u.id=fk_authorid
    WHERE c.fk_postid=?
    ORDER BY c.created DESC`;
    return db.query(baseSQL, [postId])
        .then(([results, fields]) => {
            return Promise.resolve(results);
        }).catch(err => Promise.reject(err));
};

Error:

      code: 'ER_BAD_FIELD_ERROR',
  errno: 1054,
  sql: 'SELECT u.username, c.comment, c.created, c.idn' +
    '    FROM comments cn' +
    '    JOIN users un' +
    '    on u.id=fk_authoridn' +
    "    WHERE c.fk_postid='''1'''n" +
    '    ORDER BY c.created DESC',
  sqlState: '42S22',
  sqlMessage: "Unknown column 'c.created' in 'field list'"
}

Any help would be appreciated!

how do I copy background html code of a div

I’m making a free custom website creator tool with drag and drop.
One can make the desired page by dragging elements to a div section which is then reviewed.
I want the user to copy the code inside that div section so he may be able to use it.
I’m totally new to java so I don’t know how to do so.
Please help me that how can I copy The code inside a div. So, I may be able to help people to generate their own custom templates without paying a single dollar.

note: this is a static website so nothing is being done on the server.

discord.js v13 slash commands not setting

The way my slash command handler works is I iterate through all the current client guilds, add an object to an array with the keys ‘id’ and ‘commands’, id being an integer of the guild id and commands being an array.

Then, iterate through the commands directory, require the file, check if the slash command builder has a ‘guilds’ element, in which the code will iterate through the guilds element and add the command builder to every guild commands array in the beforementioned guild array.

Then, once all is complete, iterate through the guilds array, find the guild by id, commands.set. All is working, except it only adds the commands to one of the guilds. In the iteration forEach of the guild array, I’ve made it console.log the id of the guild, and console.log after the setting of the commands. Both log properly, no errors thrown, but only my original testing server has the commands registered, and not a new server that a friend owns.

Ensured all intents are valid, administrator issued and role is high as it needs to be. Super confused!

    let guilds = []

    client.guilds.cache.forEach(guild => {
        guilds.push({
            id: guild.id,
            commands: []
        })
    })

    function addToGuild(id, obj) {
        guilds.forEach(guild => {
            if (guild.id == id) {
                guild.commands.push(obj)
                return true
            }
        })
    }

    fs.readdirSync(`${process.cwd()}/commands`).forEach(file => {
        if (file.endsWith('.js')) {
            let requiry = require(`${process.cwd()}/commands/${file}`)
            if (requiry.command.guilds) {
                requiry.command.guilds.forEach(guild => {
                    addToGuild(guild, requiry.command)
                })
            } else {
                guilds.forEach(guild => {
                    guild.commands.push(requiry.command)
                })
            }
        }
    })

    guilds.forEach((guild) => {
        console.log(guild.id)
        client.guilds.cache.find(guild => guild.id == guild.id).commands.set(guild.commands)
    })

Trying to find biggest number of a input (javascript)

I’ve got a problema running now that is: I need a function that find the highest number made by consecutive digits within that number that I received by the parameter.
For example: If my input is 1235789 my output should be 789. If my input is 123689, my output should be 123.

function getbiggestNumber(numberInput) {
    const numberString = numberInput.toString(); // turned into string

    const temporaryResult = []; // create the array of possible solutions which i'd go through to find the highest value inside of it

    for (let i = 0; i < numberString.length; i += 1) {
        const temporary = [numberString[i]]; // create a temporary answer that would serve as a base

        for (let x = i + 1; x < numberString.length; x += 1) {
            const subResult = Number(numberString[i]) - Number(numberString[x]); // the result of the current number minus the following number

            if (subResult === -1) { // if they are in a sequence this should be -1
                temporary.push(numberString[x]); // pushing this number to that temporary answer
            } // here should be some condition for it to keep running, instead getting into another number of for loop
        }
        temporaryResult.push(temporary); //  pushing that temporary answer to the result, so I could keep track of it
    }
    console.log(temporaryResult); //  checking the output
}

The problem is that this code is only providing double digits inside a array, and that was the only way I found to do this.
I’d be really thankful if someone could give me a light on this.
Thanks!

Script new function with id [closed]

how can I implement such a function with specific id’s?

a specific id should be inserted at the end of the ‘mySwiper’ variable. For example ‘mySwiper123’ via function (id)

i cant give more deteils… i thing you check this problem!

Thank you for Helping

function newFunctionWithId(id) {
var mySwiper+id = new Swiper('.divid'+id, 
    {
     // more ///
    });
}

How to check for special characters inside of a password using javascript

My code is setup to check for special characters inside of a given password. The program is suppose to store true to a variable if a special character was found, and false if one was not found; Afterwards, it will print the result of the variable. The problem is the program keeps printing out false even when there’s a special character inside of the password. I don’t know what’s wrong

const arrayOfSp = ["!", "@", "#", "$", "%", "&", "*", "_", "-", "?"];
const password = "Patrick_";
let specialCharacterCheck = false;

const special = (c) => {
    for (i = 0; i < arrayOfSp.length; i++)
    {
        if (c === arrayOfSp[i])
        {
            return true;
        }
    }
    return false;
}

for (i = 0; i < password.length; i++)
{
    if (special(password[i]))
    {
        specialCharacterCheck = true;
    }
}
console.log(specialCharacterCheck);

‘KeyboardEvent.keyCode’ modifier on ‘v-on’ directive is deprecated. Using ‘KeyboardEvent.key’ instead in vue

I am migrating my application vue 2 to vue 3. While running the application, i am getting some deprecation error.

In my keyboard event modifier, i was using numbers and key for keyboard event. But, this concept is deprecated so i am getting errors. I am not sure how to use it now?

Previously

 @keyup.ctrl.86="onUpdateEvent()"

I am getting error because of using numbers. How to resolve those?

Nested CatchBoundaries not getting called on router 404

I have a simple hierarchy like so:

root.tsx (CatchBoundary A)
routes
| main
| | index.tsx
| index.tsx (redirects to /main) (CatchBoundary B)
| main.tsx (CatchBoundary C)

I can navigate to /main and see my DOM correctly root -> main -> main/index

Now, when trying a route that does not exist: /main/foo, I would expect the CatchBoundary inside main.tsx (CatchBoundary C) to handle the error. Instead, the error bubbles all the way up to root CatchBoundary A. It skips CatchBoundary C and B.

Removing CatchBoundary A will result in an “unhandled thrown response” error.

Each CatchBoundary is declared the same way:

export function CatchBoundary() {
    console.log('[A/B/C]');
    return (<p>Caught at [A/B/C]</p>);
}

ErrorBoundaries, on the other hand, work as expected. Throwing within loader() will correctly stop at the nearest ErrorBoundary (written similarly).

Why isn’t my .obj file loading into my scene?

I cannot for the life of me figure out why my .obj model is not loading into my WebGL scene. I have tried multiple loaders (OBJLoader and ObjectLoader). I can get a cube, with a pointlight and ambient light, as well as lines drawn but the object will not show up no matter what I do. The .obj file is in the same folder as the .html file.

function loadModel(){
            var objLoader = new THREE.ObjectLoader();

            objLoader.load(
                
                'bunny-5000.obj',

            
                function ( object ) {
                    
                    object.position.set(0,0,0);
                    scene.add( object );
                    document.querySelector('h1').style.display = 'none';
                } );

This is my load method which I call at the same place as my loadAxes() method, so it is definitely being called it just is not loading.

<!DOCTYPE html>
<html lang="en">

<head>
    
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <style>
        body {
            margin: 0;
            overflow: hidden;
        }

        canvas {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <script src="three-r134.js"></script>
    <script src="three.js"></script>
    <script src="OBJLoader.js"></script>
    <script src="MTLLoader.js"></script>
    <script src='https://mamboleoo.be/learnThree/demos/OBJLoader.js'></script>
    <script>
        
        THREE.Cache.enabled = true;
        
        init();
        animate();

        document.addEventListener('keydown', handleKeyDown);

        
        function init() {
            scene = new THREE.Scene();

            
            camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
            camera.position.set(1, 2, 15);
            camera.lookAt(new THREE.Vector3(0, 0, 0));

            
            scene.add(new THREE.GridHelper(10, 20, 0xffffff));

            
            const geometry = new THREE.BoxGeometry(1,1,1);
            const material = new THREE.MeshBasicMaterial( {color: 0xFFCC00 });
            const cube = new THREE.Mesh( geometry, material);
            cube.position.set(0, 2, 0);
            scene.add(cube);

            
            scene.add(new THREE.AmbientLight(0xffffff));
            
            light = new THREE.PointLight(0xFFFFFF, 0.5 ,1000);
            light.position.set(10,0,25);
            scene.add(light);

            
            renderer = new THREE.WebGLRenderer({ antialias: true });
            renderer.setPixelRatio(window.devicePixelRatio); // HiDPI/retina rendering
            renderer.setSize(window.innerWidth, window.innerHeight);
            renderer.setClearColor("#e5e5e5");
            document.body.appendChild(renderer.domElement);

            
            window.addEventListener('resize', handleResize, false);

            raycaster = new THREE.Raycaster();
            mouse = new THREE.Vector2();

            loadAxes();
            loadModel();


        }
        function loadModel(){
            var objLoader = new THREE.ObjectLoader();

            objLoader.load(
                'bunny-5000.obj',
                function ( object ) {
                    // Add the loaded object to the scene
                    object.position.set(0,0,0);
                    scene.add( object );
                    document.querySelector('h1').style.display = 'none';
                } );
        }
        
        function handleResize() {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        }

        
        function animate() {
            requestAnimationFrame(animate);
            renderer.render(scene, camera);

        }


        function loadAxes() {
            
            const xPoints = [];
            xPoints.push( new THREE.Vector3( - 10, 0, 0 ) );
            xPoints.push( new THREE.Vector3( 10, 0, 0 ) );
            
            const xAxisGeometry = new THREE.BufferGeometry().setFromPoints( xPoints );
            const xAxisMaterial = new THREE.LineBasicMaterial( { color: 0xFF0000 } );
            const xAxis = new THREE.Line( xAxisGeometry, xAxisMaterial );
            scene.add( xAxis );
            //y axis
            const yPoints = [];
            yPoints.push( new THREE.Vector3(0, -10, 0 ) );
            yPoints.push( new THREE.Vector3(0, 10, 0 ) );
            
            const yAxisGeometry = new THREE.BufferGeometry().setFromPoints( yPoints );
            const yAxisMaterial = new THREE.LineBasicMaterial( { color: 0x008000 } );
            const yAxis = new THREE.Line( yAxisGeometry, yAxisMaterial );
            scene.add( yAxis );
            //z axis
            const zPoints = [];
            zPoints.push( new THREE.Vector3(0, 0, -10 ) );
            yPoints.push( new THREE.Vector3(0, 0, 10 ) );
            
            const zAxisGeometry = new THREE.BufferGeometry().setFromPoints( zPoints );
            const zAxisMaterial = new THREE.LineBasicMaterial( { color: 0x0000ff } );
            const zAxis = new THREE.Line( zAxisGeometry, zAxisMaterial );
            scene.add( zAxis );
        }


        
        function handleKeyDown(event) {
            switch (event.key) {
                // Render modes.
                case 'f': // f = face
                    
                    break;

                case 'e': // e = edge
                    
                    break;

                case 'v': // v = vertex
                    
                    break;
            }
        }
    </script>
</body>

</html>

I post the entire code for the sake of context. Is there a problem with my project file structure I am not aware of? Or am I doing something dumb in the method?

Google App Script: GAS return 403 but browser requests still work

I’m using google app script to monitoring URL is working then writing log in excel after every 30 mins:

  try {
    var options = {
      "method" : "GET",
      'headers': {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36'
      },
      'muteHttpExceptions': true
    };
    var url_trimmed = url.trim();
    var response = UrlFetchApp.fetch(url_trimmed, options);
    Logger.log(response.getContentText()); 
    var result = response.getResponseCode();
    return result;
  }
  catch (err) {
    return [EXCEPT_ERR_CD, Utilities.formatString('statusCode: %s、Error: %s)', EXCEPT_ERR_CD, err)];
  }
}

But when I check Excel result file, result sometimes return responseCode 200, and sometimes return 403. Immediately when responseCode returns 403, I check it in browser but site is working fine.
I tried add header parameter but it doesn’t work.
I dont have any idea, I think maybe the error from the site but dont really know causes and how to fix it.
Thank you very much.