Solved

jQuery and Repeater

Posted on 2011-03-04
3
684 Views
Last Modified: 2012-05-11
If the user inputs a numeric value into the quantity text box, then I would like to set the price and total textboxes to "0.00"
for that row only.

Please see the screen shot, all the textboxes in all rows changed.
How can I limit it by row?

    $(document).ready(function () {
        $("[id$='_txtQuantity']").blur(function () {
            var quantity = $("[id$='_txtQuantity']").val();
            if (isNumeric(quantity)) {
                $("[id$='_txtPrice']").val('0.00');
                $("[id$='_txtTotal']").val('0.00');
            }
        });
    });

    function isNumeric(n) {
        return !isNaN(parseFloat(n)) && isFinite(n);
    }
 
screen shot
0
Comment
Question by:JRockFL
3 Comments
 
LVL 13

Expert Comment

by:agarwalrahul
ID: 35041572
Please read the documentation:

http://api.jquery.com/val/
0
 
LVL 10

Accepted Solution

by:
P1ST0LPETE earned 500 total points
ID: 35041655
Each row in the repeater should have a unique numeric identifier of some sort.  For example you should have something like:

    _txtQuantity1
    _txtQuantity2
    _txtQuantity3
    etc.....

Then you just need to find the unique identifier (i.e. row index) using javascript.  Then once you have the identifier, you should be able to locate the price and total textboxes fairly easily.  Something like this:

$('[id*="_txtQuantity"]').blur(function ()
{
       var rowIndex = this.id.substring(12, 1);  //should strip out the "_txtQuantity" just leaving the number
       var quantity = $(this).val();
       var price = $('[id*="_txtPrice' + rowIndex + '"]').val();
       $('[id*=_txtTotal' + rowIndex + '"]').val(quantity * price);
});
0
 
LVL 8

Author Closing Comment

by:JRockFL
ID: 35043328
Perfect, thank you
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question