CODEQUEENtutorial}

Checkboxes: Set Value to Single Field on Button Mouse In

Test it out:

Monday

Tuesday

Wednesday

Thursday

After you create your checkboxes, activate the 'on click' event in the properties panel:

For your button, activate the 'mouse in' event in the properties panel:

The code on the page for the example above:

$w.onReady(function () {
    $w("#checkbox1").value = '';  //by having ' ' it makes the value equal 'nothing' when the page is loaded
    $w("#checkbox2").value = '';
    $w("#checkbox3").value = '';
    $w("#checkbox4").value = '';

});

export function checkbox1_click() {
    dayMonday();
}

export function checkbox2_click() {
    dayTuesday();
}

export function checkbox3_click() {
    dayWednesday();
}

export function checkbox4_click() {
    dayThursday();

 

//because the page started with all the value to equal 'nothing', now we will set the values to equal the real value

function dayMonday() {
            if ($w("#checkbox1").value === '') {
            $w("#checkbox1").value = 'monday';    
            }
            else {
                $w("#checkbox1").value = '';
            }
}

function dayTuesday() {
            if ($w("#checkbox2").value === '') {
            $w("#checkbox2").value = 'tuesday';    
            }
            else {
                $w("#checkbox2").value = '';
            }
}

function dayWednesday() {
            if ($w("#checkbox3").value === '') {
            $w("#checkbox3").value = 'wednesday';    
            }
            else {
                $w("#checkbox3").value = '';
            }
}

function dayThursday() {
            if ($w("#checkbox4").value === '') {
            $w("#checkbox4").value = 'thursday';    
            }
            else {
                $w("#checkbox4").value = '';
            }
}

function valueCombine() {
    let checkedValue = $w("#checkbox1").value + " " + $w("#checkbox2").value + " " + $w("#checkbox3").value + " " + $w("#checkbox4").value;
    $w("#testValue").value = checkedValue;
}


export function submitButton_mouseIn() {
    valueCombine();
}

Was this tutorial helpful?
  • Facebook - Black Circle
  • Totally Codable
This site was designed with the
.com
website builder. Create your website today.
Start Now