473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Number of Likes increases when page is refreshed.

85 64KB
Dear all,
i want to update the number of likes increased when the user clicks on the like button. like on my site , when on this page
http://modelspk.com/urwa-tul-wusqa-model18
user clicks on the like button, the no of likes in increased by one in the database. but until the page is not refreshed, it is not updated at the front end. the code currently i am using is as follows
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.         $("#likeThis").live("click", function () {
  3.             var pid = document.getElementById("pid");
  4.             var uRL = "/updateRatings.aspx?opt=1&pid=" + pid.value;
  5.             $.post(uRL);
  6.             alert('You Like This');
  7.             this.disabled = true;
  8.             document.getElementById("dislikeThis").disabled = true;
  9.             return false;
  10.         });
  11.  
  12.         $("#dislikeThis").live("click", function () {
  13.             var pid = document.getElementById("pid");
  14.             var uRL = "/updateRatings.aspx?opt=2&pid=" + pid.value;
  15.             $.post(uRL);
  16.             alert("You don't Like This");
  17.             this.disabled = true;
  18.             document.getElementById("likeThis").disabled = true;
  19.             return false;
  20.         });         
  21.  
  22.     </script>
  23.  
and the html input button for like or dislike are as follows..
Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.                         <td>
  3.                             <asp:HiddenField ID="newPhotoID" runat="server" />
  4.                             <input type="hidden" id="pid" value="<%=ModelID%>" />
  5.                             <asp:Label ID="lblModelID" runat="server" Visible="false"></asp:Label>
  6.                             <table width="253" align="center">
  7.                                 <tr>
  8.                                     <td align="left" class="txt" style="color: #0068c6; font-weight: bold;">
  9.                                         Rate This:
  10.                                     </td>
  11.                                     <td align="center" class="WaterText">
  12.                                         <input type="image" id="likeThis" onclick="javascript:rateThis(1,<%=ModelID%>);"
  13.                                             src="/images2/inact-thumb.jpg" onmouseover="this.src='/images2/active-thumb.jpg'"
  14.                                             onmouseout="this.src='/images2/inact-thumb.jpg'" />&nbsp;<%=Likes%>
  15.                                         <span class="txt" style="color: #0068c6; font-weight: bold;">Likes</span>
  16.                                     </td>
  17.                                     <td align="center" class="WaterText">
  18.                                         <input type="image" id="dislikeThis" src="/images2/no-inact.jpg" onclick="javascript:rateThis(2,<%=ModelID%>)"
  19.                                             onmouseover="this.src='/images2/no-active.jpg'" onmouseout="this.src='/images2/no-inact.jpg'" />&nbsp;<%=Dislikes%>
  20.                                         <span class="txt" style="color: #0068c6; font-weight: bold;">Disikes</span>
  21.                                     </td>
  22.                                 </tr>
  23.                             </table>
  24.                         </td>
  25.                         <td width="127" align="right" class="WaterText">
  26.                             <%=Views %>
  27.                             <span class="txt" style="color: #0068c6; font-weight: bold;">Views</span>
  28.                         </td>
  29.                     </tr>
  30.  
what i want to do is that as the user clicks on the like button, it should be increased by one at the same time without refreshing the page.


Regards:
Mudassir
Jun 10 '13 #1
1 1327
Rabbit
12,516 Expert Mod 8TB
In your click function, have it add one to the current value.
Jun 10 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: NotGiven | last post by:
I am guessing I would hold a variable of when it's opened, then in the script that runs when the page is offloaded, I coudl calcualte it. How do you store a time variable? How do you calculate...
1
by: abdul bari | last post by:
Hi I have a standard html form which is generated by an XSL sheet. The form data is submitted to the server and is passed on to file.aspx for processing. However file.aspx is refreshed every 5...
0
by: sanjay patil via .NET 247 | last post by:
Hello, I have a problem with web image button control click event. I am saving a record to database on click event of this image button. When click event fires first time it executes code...
1
by: lalitha1024 | last post by:
Hi, In my Asp.net project, i am using datagrid to show results, whic included custom sorting, custom paging and option to select number o rows per page using radio button list. it works very fine....
1
by: mark | last post by:
Hi I am trying to count the number of times a page loads. When I hit the submit button I can get the page to count once using ispostback to check . I am trying to incriment a variable everytime...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
1
by: vssp | last post by:
hai friends How to paly song when page laod using php code? I my php application when i load the home page automatically pale song Its possible !! ??Please give me any idea Thanks vssp...
5
by: mail2kondeti | last post by:
Hi Here I need know small clarification. I did this long time back. If I want to show the cursor in the first field when the page gets loaded, how we have to do? Ex. if you goto...
6
by: sattu | last post by:
i want to store value of querystring("id") when page postback
3
NawazAhmed
by: NawazAhmed | last post by:
Hi, I am working with Visual Studio 2003, framework 1.1 I am trying to focus a textbox when page loads. I tried Page.RegisterStartupScript("focus",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.