Solved

jQuery and Repeater

Posted on 2011-03-04
3
686 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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 …

734 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