Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Submit form using JQuery won't append to list

I need to be able to append to a list (it's a leaderboard, but that's not relevant) by submitting through a form and appending to an ordered list using jquery. When I press submit nothing happens other than the button being pressed. Where am I going wrong?

HTML:

<main>
  <ol class="playerList">
    <li>Profit - 12,565</li>
    <li>carpe - 11,423</li>
    <li>Fate  -  11,003</li>
    <li>Fleta  -  10,931</li>
    <li>Fury  -  10,704</li>
    <li>Gesture  -  10,601</li>
    <li>Choihyobin  -  10,012</li>
    <li>MekO  -  9,879</li>
    <li>Birdring  -  9,850</li>
    <li>Mano  -  9,766</li>
  </ol>
</main>

<footer>
    <form id="submissionForm">
      <label id="nameLabel" for="pName"><u>Player name:</u></label>
      <input id="pName" type="text" placeholder="Enter player name...">
      <label for="pElims"><u>Elimination Count:</u></label>
      <input id="pElims" type="text" placeholder="Enter elimination count...">
      <input id="submitBtn" type="submit">
    </form>
</footer>

JQuery:

$(document).ready(function() {

$("#submissionForm").on('submit', function(event){
    event.preventDefault();
    error = false;
    $(".error").hide();
    var playerName = $("#pName").var();
    var elimCount = $("#pElim").var();
    var newItem = (playerName + "  -  "+ elimCount);

    $('.playerList').append('<li>'+ newItem + '</li>');
    return false;
   });
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.var() is not a valid way to get an input element's value. Also, the id on the elim count does not match the id on the HTML element.

var playerName = $("#pName").var();
var elimCount = $("#pElim").var();

It should be:

var playerName = $("#pName").val();
var elimCount = $("#pElims").val();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!