In one of my smart contracts I have the following function:

function dosomething(bool _okl) {
    if (_okl == false){
        boola = true;
        boolb = false;
    } else {
        boolb = true;

I have a frontpage where bool _ok can be filled in by an input field:

input type="text" name="_okl" id="_okl" placeholder="true or false" 

and button:

button id="button3">OK? button

this button is triggering my dApp.js in the following way:

$("#button3").click(function() {
    contractED.dosomething({value: $("#_okl").val()}, function(err, result) {
        console.log(err, result);

For some reason, if I enter false in _okl, my contract doesn't recognize it as such in the logical check. What am I doing wrong here? It is triggering the function just fine, but always goes directly to the else part of my function.

Anyone any idea?

1 Answer 1


Maybe $("#_okl").val() return a String, and therefore _okl is always true

  • Solved it in the end by creating seperate functions with corresponding seperate buttons to update booleans to either true or false. Apr 25, 2017 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.