-5

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?

1
  • sorry about the weird for loop i just didnt know how else to express it in code so i did that which i know is invalid syntax lol Commented Jul 19, 2017 at 19:27

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.