You can just grab it using :
var mycheckbox1 = document.getElementById('checkbox1');
and
var mycheckbox2 = document.getElementById('checkbox2');
You might want to change your checkbox2's id to id='checkbox2' having non-unique id is not valid syntax.
If you were asking to modify the function you posted then it's the following:
<input type ="checkbox" id = "checkbox1" checked ="checked" value="1" onclick = "a()"/>
<input type ="checkbox" id = "checkbox2" checked ="checked" value="2" onclick = "a()"/>
function a(){
var mycheckbox1 = document.getElementById('checkbox1');
var mycheckbox2 = document.getElementById('checkbox2');
if(mycheckbox1.checked && !checkbox2.checked)
alert('checkbox1 is checked, checkbox2 is unchecked');
}
Now if you were asking to get the value of the checkbox that is checked then it's the following:
<input type ="checkbox" id = "checkbox1" checked ="checked" value="1" onclick = "a(this)"/>
<input type ="checkbox" id = "checkbox2" checked ="checked" value="2" onclick = "a(this)"/>
function a(box){
if(box.checked)
alert(box.value);
}