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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:21:24+00:00 2026-06-14T17:21:24+00:00

Possible Duplicate: Unable to get textfield value using jQuery I am trying to change

  • 0

Possible Duplicate:
Unable to get textfield value using jQuery

I am trying to change the input field when users changes the quantity of items in a text field. Here I am iterating through my list from my database. Now I have to make an invoice for customer.

In my code, if I am changing the quantity of a single item, then it is affecting all the other items in the list. I want to change only the specific items, where its quantity has been changed.

The code below is giving me an error. It is changing all the items value on single change of item quantity.

My code: (New Update)

          <script type="text/javascript">
             $(document).ready(function(){  
                $(function() {        
                   $('input[name="quantity"]').change(function() {
                    var $tr = $(this).closest("tr");
                    var unitprice = $tr.find('input[name^="unitprice"]').val();  
                    $tr.find('input[name^="price"]').val($(this).val() * unitprice);
                }); 
                var totalPrice = 0;
                $('input[name="price"]').each(function(){
                    totalPrice += parseFloat(this.value);
                    $('[name=subtotal]').val(totalPrice);
                });
            }); 
        }); 
        </script>
         ..................
         ..................
         <tr>
            <td height="65%" valign="top" width="100%"> 
                <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                    <s:iterator  value="#session.BOK" status="userStatus">
                        <tr style="height: 10px;"> 
                            <td width="65%" align="left"><s:property value="bookTitile"/></td> 
                            <td width="10%" align="left"><s:textfield name="unitprice" value="%{price}" size="4"/></td>
                            <td width="10%" align="center"><s:textfield name="quantity" value="1" size="2"/></td>  
                            <td width="15%" align="center"><s:textfield name="price" value="%{price}" size="6"></s:textfield> </td>
                        </tr> 
                    </s:iterator>  
                </table>   
                </td>
            </tr> 
              <tr>
                   <td height="1%" valign="top" width="100%"> 
                          <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
                                       <tr style="height: 10px;"> 
                                           <td width="100%" align="right" colspan="5">   
                                                <s:textfield name="subtotal"  size="5"> </s:textfield>
                                          </td>
                                       </tr> 
                           </table>  
                 </td>
          </tr>

The output looks like this image:

enter image description here

  • 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-14T17:21:25+00:00Added an answer on June 14, 2026 at 5:21 pm

    Try this instead

    <script type="text/javascript">
        $(function() {        
            $('input[name="quantity"]').change(function() {
                var $tr = $(this).closest("tr");
                var unitprice = $tr.find('input[name^="unitprice"]').val();  
                $tr.find('input[name^="price"]').val($(this).val() * unitprice);
            });
        });
    </script>
    

    Update : This the function that will return the total caculated price. Use it as per need.

    function calculateBasket() {
        var totalPrice = 0;
        $('input[name="price"]').each(function(){
            totalPrice += parseFloat(this.value);
        });
    
        return totalPrice;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Unable to change DataRow value I bound a datatable to a datagrid.
Possible Duplicate: Unable to locate tools.jar I'm trying to use ant to compile using
Possible Duplicate: Android RuntimeException: Unable to instantiate the service Trying to get GCM up
Possible Duplicate: Unable to Populate TableView In PopOverController - Objective C I am using
Possible Duplicate: Unable to get a list of installed Python modules How do I
Possible Duplicate: Unable to connect to internet in Blackberry device? I'm trying to send
Possible Duplicate: Ivy fails to resolve a dependancy, unable to find cause I'm trying
Possible Duplicate: Unable to do File Upload in PHP I am trying to learn
Possible Duplicate: jQuery compiled with Google Closure Compiler I am using jQuery and I
Possible Duplicate: error: Unable to find vcvarsall.bat I'm trying to install MySql interface for

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.