dimanche 25 juin 2017

Sending a checkbox input on off value?

I'm trying to submit a checkbox on off mode (when it is unchecked) when I click on the star ($star; and $starf), I've tried many things, and one with a hidden field, here's what I've done

    if(document.getElementById('checkbox').value="$star;"){
        document.getElementById('checkbox').onclick = function() {
        document.getElementById('checkbox').innerHTML = '$starf;';
        var onoff="on";
        document.getElementById('onoffhiddeninput').value=onoff;

    }}else{

        document.getElementById('checkbox').onclick = function() {
        document.getElementById('checkbox').innerHTML = '$star;';
        var onoff="off";
        document.getElementById('onoffhiddeninput').value=onoff;

    }

I'm trying to set the value of the hidden input field on 'on' or 'off' in the hidden field but I don't know why it's not working, can someone help me please ?




Aucun commentaire:

Enregistrer un commentaire