Link to home
Start Free TrialLog in
Avatar of sai kiran reddy
sai kiran reddy

asked on

like button for every video

hello, iam trying to do a video player project for that i would like to keep like buttons and i have did that for all videos in only one single page but my problem is i kept one id for all videos  calling function for all videos but while im hitting like button it is counting for only one video like button not for another like button please help me
<html>
<head>
<script>
var Clicks = 0 ;
function AddClick(){
Clicks = Clicks + 1;
document.getElementById('CountedClicks').innerHTML = Clicks + ' Hits';
}
</script>
</head>

<body>
<button id="CountedClicks" type="button"></button><br>
<button style="background-color:green" >Count Your Hit</button>
<br>
<button id="CountedClicks" type="button"></button><br>
<button style="background-color:blue" onclick="AddClick()">Count Your Hit</button>
</body>

</html>

Open in new window

Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Not sure what you're after, but you can't use the same ID more than once in a page - it has to be unique.

If you can explain what you need we can probably help you out.
Avatar of sai kiran reddy
sai kiran reddy

ASKER

Thank you Chris Stanyon, my problem is how to give counter like button for different videos different like buttons different counting .... like if you like one one video another video is been liked that should not happen ... which video iam liking that video only b liked
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hey Chris Stanyon
i need permanent hit counter could you please help me for the same question
There would be quite a few moving parts to implement a permanent hit counter. You would need some form of persistent storage, probably a database. You would need to give each of your videos a unique ID. You would need to write an AJAX script to push the video ID back to the server to be stored in the DB. You would need to query the database on your video page to show the current number of likes. You may also want to implement some form of checks to stop the same person continuously clicking on the like button.

It's not a simple one-answer solution. You would need to plan it out properly and then implement all the various moving parts.

My advice would be to do a Google search on how best to achieve this using something like PHP / jQuery. That should give you some good ideas on how you want to implement it. You can then come back to EE to ask specific questions about any of the parts you're struggling with.