Save undefined value from checkbox


I have checkbox and I need to get his value.

I create function for checkbox if checkbox is clicked it is true then the checkbox value is H else W.

function chk(){

 var H = document.getElementById('H'). value = H;

else if(document.getElementById('H').checked==false){
var H = document.getElementById('H'). value = W;


and I have function for save :

function ApproveLeaveOP(){
    var H = document.getElementById('H').value;

<input type="checkbox" name="H" id="H" value="" onclick="chk()">

I don’t know how can I add value to the checkbox if I click the value will be H if not the value is W.

I am new in using checkbox.
Thank you so much…