Solved

jQuery and Repeater

Posted on 2011-03-04
3
682 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Editing XSL files, 2 41
Getting multiple values from a dataset ASP.NET(VB) 3 37
Class object 2 26
How to make a GridView cell hyperlinked using C# ? 3 14
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now