HTML Checkbox onclick每次都发送相同的值

I try to use two checkboxs with a value = "on". The other one is for rember after submit a form. Every time i click on this checkbox, they will always send "on".

What i do wrong ? Here is my code

var rdt = {
  updateScroll: function() {
    alert('klick scroll:' + gbi('scrollit').value);
    gbi('main').removeChild(gbi('icontent'));
    var ifr = document.createElement('iframe');
    ifr.id = 'icontent';
    ifr.src = gbi('urlinput').value;
    ifr.scrolling = (gbi('scrollit').value == 'on') ? 'yes' : 'no';
    gbi('scroll_hid').value = (gbi('scrollit').value == 'on') ? 'on' : 'off';
    gbi('main').appendChild(ifr);
    rdt.resizeView();
  }


}

function gbi(iD) {
  return document.getElementById(iD);
}
<input type="checkbox" id="scrollit" onclick="rdt.updateScroll()" checked>
<input type="hidden" name="scroll" id="scroll_hid" value="<?php echo $scroll ?>">

The parameter $scroll can predifine over URL, but the result was the same if i use it or if i dont use it.

</div>

This is because you are getting its value and its value is on. You have to get the value when it is checked like:

var value = null;
$('#scrollit').click(function(){
    if($(this).is('checked'))
    {
        value = $(this).val();
    }
});

In this case you will get its value when it is checked otherwise null

The primary intention of checkbox is to make user that the option to be checked or unchecked it is not intended to send values

You can refer this link for more details

Here is the main thing

The HTML input element allows you to select a single value for submission in a form (or not).

A solution for your problem is as follows you can check checkbox's current status ie checked or not by using following

based on your code

gbi('scrollit').checked

var rdt = {
  updateScroll: function() {
    alert('klick scroll:' + gbn('scrollit').value);
    gbi('main').removeChild(gbi('icontent'));
    var ifr = document.createElement('iframe');
    ifr.id = 'icontent';
    ifr.src = gbi('urlinput').value;
    ifr.scrolling = (gbi('scrollit').value == 'on') ? 'yes' : 'no';
    gbi('scroll_hid').value = (gbi('scrollit').value == 'on') ? 'on' : 'off';
    gbi('main').appendChild(ifr);
    rdt.resizeView();
  }
}

function gbi(iD) {
  return document.getElementById(iD);
}


function gbn(name) {
  var x = document.getElementsByName(name);
  var i;
  var element;
  for (i = 0; i < x.length; i++) {
    if (x[i].type == "checkbox") {
      element = x[i];
    }
  }
  return element;
}
<input type="checkbox" name="scroll" id="scrollit" onclick="rdt.updateScroll()" checked>
<input type="hidden" name="scroll" id="scroll_hid" value="<?php echo $scroll ?>">

</div>

add a small loop make the code more clear for me and works already

updateScroll: 

    function() {


                gbi('main').removeChild(gbi('icontent'));
                var ifr = document.createElement('iframe');
                ifr.id='icontent';
                ifr.src=gbi('urlinput').value;

        if (gbi('scrollit').value=='on' && gbi('scroll_hid').value!='on')
        { ifr.scrolling='yes'; gbi('scroll_hid').value='on';}
        else
        { ifr.scrolling='no'; gbi('scroll_hid').value='';}

                //ifr.scrolling=(gbi('scrollit').value=='on')?'yes':'no';
                //gbi('scroll_hid').value=(gbi('scrollit').value=='on')?'on':'off';
                gbi('main').appendChild(ifr);
                rdt.resizeView();
            },
            rotate: function() {
                rdt.w = parseInt(gbi('icontent').style.width);
                rdt.h = parseInt(gbi('icontent').style.height);
                gbi('icontent').style.width=gbi('icontentfoot').style.width = rdt.h+'px';
                gbi('icontent').style.height = rdt.w+'px';
            }