-4

first of all thank you for your time i really appreciate it. I am trying to use javascript to recognize if a an html checkbox was checked. Here is a code example of how i imagined it would be.

enter code here
var submit = document.getElementById("btn");
var para1 = document.getElementById("p1");
var para2 = document.getElementById("p2");
var para3 = document.getElementById("p3");
var pA = true;
var pB = true;
var pC = true;

function submitForm(){ 
    for(p1 == pA, p1 == onclick){ 

    }
}

so obviously thats not going to work but my question is basically is what im trying to do possible with javascript(im sure it is)? And how should i go about it?

LifeQuery
  • 3,202
  • 1
  • 26
  • 35

1 Answers1

2

Yes it is possible. You can check the "checked" property once you have the object of that checkbox.

var chbox = document.getElementById(id);
console.log(chbox.checked);  //true if checked,false otherwise
Abhishek Ranjan
  • 498
  • 3
  • 17