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 8046977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:57:43+00:00 2026-06-05T05:57:43+00:00

Help please, I am not quite sure how to approach this one: I have

  • 0

Help please, I am not quite sure how to approach this one:
I have an app where the client has several sections which contain several fields. Sometimes the same field appears. For example, “quantity” or “color” may appear in three, four or more sections.

When the web form is submitted, the value sent to the other end is empty because the next qty field, which is empty, will overwrite the value, thus producing an empty/null value on the other end. [there is only one quantity field on the other end]

Because of the structure of this app, which they want to maintain, I want a clear cut way of saying/do the following using jquery:

get fields #quantityOne,#quantityTwo,#quantityThree, determine which one has a value in it, take that value and place it in hidden field finalQty.

Could someone show me how to accomplish this please?

Adding one note for clarification:

The user would only be filling out ONE of the sections, thus only one
of the qty fields. So if I put 555 in qtyField #1, then 555 should be
copied to finalQty, if I put 35 in qtyField #2, then 35 should be
copied to finalQty

My code

html/jquery:

<fieldset id="sectionOne" name="sectionOne">
<legend class='legendHdrs' >Section One</legend>
Name: <input type="text" name="nameOne" id="nameOne" class="name" /><br />
Quantity: <input type="text" name="quantityOne" id="quantityOne" class="quantity"/>
    </fieldset><br /><br />

<fieldset id="sectionTwo">
<legend>Section Two</legend>
Name: <input type="text" name="nameTwo" id="nameTwo" class="name" /><br />
Quantity: <input type="text" name="quantityTwo" id="quantityTwo" class="quantity"/>
</fieldset><br /><br />

<fieldset  id="sectionThree">
<legend>Section Three</legend>
Name: <input type="text" name="nameThree" id="nameThree" class="name" /><br />
Quantity: <input type="text" name="quantityThree" id="quantityThree" class="quantity"/>
</fieldset>
<hr>

Final Qty: <input type="text" name="finalQty" id="finalQty" class="finalQty"/>
 <input type="button" value="Add Qty" id="addQty">
</form>​

    $(document).ready(function() 
{
    $('#addQty').on('click', function()
            {
            var holdval;
        $('#quantityOne,#quantityTwo,#quantityThree').each(function() 
                    {
                        if($(this).val() !== '')
                            {
                                holdval = $(this).val() 
                            }
                    });
        $('#finalQty').val(holdval);
            });

 });
  • 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-05T05:57:44+00:00Added an answer on June 5, 2026 at 5:57 am

    According to edit

    $('#addQty').on('click', function(){
           $('.quantity').each(function(){
                var val = $.trim( this.value );
                if(val){
                    $('#finalQty')val(val);
                    break;
                } 
            });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can you please help me with this issue the String class does not have
I am wondering why this is not working please help me. Here is my
Can anyone please help me with this...I'm not very good with regular expressions and
this is my snippet , please help me why the con .open is not
Not quite sure how to explain it, so showing some codes will definitely help
I'm not quite sure where to start with all of this, but im assuming
I'm not quite sure how to ask my question in C# terms, so please
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
Please help with my script is not working. @echo off echo Printing repeated character
Please help me with my understanding. Also I am not talking about SSL or

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.