Skip to content
Advertisement

How do I pass the name of the radio button to the Javascript for the onclick event?

I have an html table having n rows. Each row has a name and 2 radio buttons. If I click a radio button, I want to show an alert that states the count of votes. How should I pass the name of the radio button to the Javascript and how should I do the counting?

Here’s the PHP part:

JavaScript

and here’s the Javascript part:

JavaScript

Advertisement

Answer

You just pass it as an argument:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement