Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
hello
I have a repeater that conatins one button and one label
when you click on button the value of label increases on time( for each row ).
first in database the value will be increased then will appear in label ( for each row ).
my code is like this:

JavaScript
$(document).ready(function () {
    $('a[id*=button]').click(function () {
        var panel = $(this).parent().find('div[id*=effect]');
        if (panel.css('display') == 'none') {
            $.post("ghInsertInsViewCount.ashx", $("form").serialize(), insertCallback);
            panel.fadeToggle("slow", "linear");
            $(this).html('<img src=images/Close.png />');
        }
        else if (panel.css('display') == 'block') {
            panel.fadeToggle("slow", "linear");
            $(this).html('اطلاعات بیشتر<img src=images/down-icon.png />');
        }
        return false;
    });
});

function insertCallback(result) {
    $('aViewCount').html(result);
}

my problem is when I click on button the value of labels will be changed and equal for all rows
Thanks a lot
Posted
Updated 18-Jul-12 1:43am
v2
Comments
R. Giskard Reventlov 18-Jul-12 14:37pm    
Where's the question?
ZurdoDev 18-Jul-12 16:28pm    
This is not clear.
SinaNadi 18-Jul-12 18:08pm    
sorry I was wrong
My problem is when I click on a button all labels will be increase the same
for example all labels of all rows will be the same value

1 solution

You need to make a button that passes the id of the row you want to change, to a jquery using function. Otherwise, your code looks them all up and changes them all, obviously.
 
Share this answer
 
Comments
SinaNadi 21-Jul-12 2:05am    
how can I do that????
Christian Graus 21-Jul-12 2:09am    
Well, you emit it in the template for the row, so it's able to access the id of the row. So you emit a button with a click event that calls the function and passes in the right values.
SinaNadi 21-Jul-12 2:48am    
can you please give me an example?
I'm begginer
Christian Graus 21-Jul-12 2:57am    
Then you should learn a language, such as C#, then a framework, such as ASP.NET, then any other languages you need to know for that, like SQL and then javascript, and finally libraries like jquery. It's not possible to write copy and paste code that you could use, and it seems clear to me that anything less won't do, because you're asking me to do your work for you, not trying to learn at a reasonable pace. The code you posted, is not beginner code. Why are you working on it ?
SinaNadi 21-Jul-12 3:13am    
I'm good at C#
I just want to do actions for database without reloading the page

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900