🔒 Closed How to count radio buttons?

Status
Not open for further replies.

Netflix

Forum Veteran
Can anybody help me how to count all the radio buttons that is selected?
Assume I have 15 buttons
Code:
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">
<input type="radio" name="kagawads">


</body>
</html>


what do you prefer radio button or check box?
I would like to use this as a validation , user can only select less 7 or equal to 7.
TIA!
 
<form action="" method ="">
<input type="radio" name="kagawads1">
<input type="radio" name="kagawads2">
<input type="radio" name="kagawads3">
<input type="radio" name="kagawads4">
<input type="radio" name="kagawads5">
<input type="radio" name="kagawads6">
<input type="radio" name="kagawads7">
<input type="radio" name="kagawads8">
<input type="radio" name="kagawads9">
<input type="radio" name="kagawads10">
<input type="radio" name="kagawads11">
<input type="radio" name="kagawads12">
<input type="radio" name="kagawads13">
<input type="radio" name="kagawads14">
</form>

other file
count.php
conditional statement if(get(variables...))
then sum all variables
then you have the sum of all click buttons
 
how to count dynamic radio buttons selected using javascript

paste on google search hope this will help
 
Eto yung solution ko sa prob mo. Mas ok na checkbox para makapag select ka ng multiple. Tapos gawa ka nalang ng onclick event para ma-update mo yung current count ng selected checkboxes tapos dun mo narin i-validate.


<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<input type="checkbox" name="kagawads" checked>
<input type="checkbox" name="kagawads">
<input type="checkbox" name="kagawads" checked>
<input type="checkbox" name="kagawads" checked>
</body>
<script>
var count = document.querySelectorAll('input[type=checkbox]:checked').length;
console.log(count);
</script>
</html>
 
Thank you everyone.
I managed to do the work , through Php and ajax for setting and getting the multiple values in an array.

Thanks!
 
Status
Not open for further replies.

About this Thread

  • 10
    Replies
  • 729
    Views
  • 7
    Participants
Last reply from:
pusangitim13

Online now

Members online
402
Guests online
928
Total visitors
1,330

Forum statistics

Threads
2,275,095
Posts
28,960,628
Members
1,233,594
Latest member
baam
Back
Top