I need to pass checkbox Boolean value(True or False) from below java method to java script function.

Java Method::

```
M1() {
  generatedXML.append("<div id=checkboxes> ");
  generatedXML.append("<input type=checkbox ");
  generatedXML.append(" onchange=\"setValue('");
  generatedXML.append(obj);
  generatedXML.append("','");
  generatedXML.append('this');
  generatedXML.append("');\"");
}

```

JavaScript function::

```
function setValue(obj,refr) 
{
  alert(refr.checked); // i think it will alert true or false??
  //Need Boolean value of checkbox 
}

```
['https://Stackoverflow.com/questions/37694419', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4873517/']
You should add an id attribute to the checkbox and in the javascript access the checkbox itself by its own id. Something like

```
document.getElementById('checkIdHere');

```
Assign your checkbox with an ID and in `onchange` function access checkbox with that id or you can pass the instance of checkbox to `onchange` function and directly access the value of checkbox.

```
var value = document.getElementById("chkTest").checked

```

And if you want to access value without `id` than pass `this` to `onchange` function from java like (syntax may not be correct please ignore as i don have editor for this)

```
generatedXML.append(" onchange=\"setValue('");
generatedXML.append(obj);
generatedXML.append("','");
generatedXML.append(path);
generatedXML.append("',this);
generatedXML.append(");\"");

```

And in javascript do this

```
function setValue(obj,path,chkBox) {
var value = chkBox.checked;
}

```