Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8234503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:30:07+00:00 2026-06-07T18:30:07+00:00

I have a form where people enter elements and it autogrows. I wanted to

  • 0

I have a form where people enter elements and it autogrows. I wanted to do some math on the data being entered but I’m having problems capaturing the contents of the input field. Here’s the original program I’m working with ( http://jsfiddle.net/doktormolle/WaL84/ ) and I did some reading and believe .eq is the command I need to get the second last element of the auto growing list(I can’t get the last element because its always blank on a auto growing list).

My end goal would be to take all the numbers and return the total or average,etc…

I tried var from = $("#siblings").eq(-1).val(); and -2 but it keeps giving me the value of only the first cell(for example if I enter 1,2,3,4,5 on each cell then I’ll keep getting 1).

If it helps here’s the code:

$(document).ready(function () {
    $("input[name='siblings']").on('keydown',
        function()
        {

           //is it the last input?
           if(this==$("input[name='siblings']:last",this.form)[0])
           {
            //insert an empty clone of the current input
            $(this).after($(this).clone(true).val(''));

           var from = $("#siblings").eq(-1).val();

           $("div#total").append("value = " + from + "<br>");       
           }
         });        
});

html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script type="text/javascript" src="input.js">
</script>
<style type="text/css">
input{display:block}​
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p> test </p>
<form>
    <div id="inputform" name="inputform">
        <input id="siblings" name="siblings"> 
    </div>
</form>
<div id="total">
hello
</div>
&nbsp;
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:30:09+00:00Added an answer on June 7, 2026 at 6:30 pm

    First, the condition in the if() clause is confusing if not actually wrong.

    Second, I think you want to get the value from the input element on which the keydown event fired, in other words simply this or $(this), inside the handler. There’s no point getting the value from the freshly cloned element because it has been deliberately emptied.

    Try this :

    $("input[name='siblings']").on('keyup', function(e) {
        if(e.which === 9) return;
        var $this = $(this);
        if (this == $this.siblings().andSelf().last().get(0)) {
            //insert an empty clone of the current input
            $this.clone(true).val('').insertAfter(this);
            $("div#total").append("value = " + $this.val() + "<br>");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form page where users enter some data and upon hitting 'submit'
i have seen people localize their form using resource. put text data in resource
I have form that I want people to fill out but if they are
I have a form that, for example, allows people to enter all their siblings.
I have a form view which people use to update a record in the
I have a form with a list of people with check boxes next to
Well i have a form in site where people submit domains to my database,
You have to have a form on your website for people to send an
Let's say I have a form where users can search for people whose name
I have a small form that I want to have people fill out on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.