Google Sheets using JavaScript functions and check box












0














I want to use the "check box" operation of google sheets, and when the check box is true, then call to a function.
Someone can help me with that ?










share|improve this question






















  • What do you mean by Check Box? As in an input field checkbox?
    – GrandIQ
    Nov 22 at 20:44










  • A new feature that enable to create a clickable check box that return true or false on a click. I want to associate the check box to a function.
    – Ido Segal
    Nov 22 at 20:48










  • Are you trying to do this with HTML and Javascript? The google-sheets part is confusing me, does it need to relate to google-sheets or do you want an example of check boxes?
    – GrandIQ
    Nov 22 at 20:50
















0














I want to use the "check box" operation of google sheets, and when the check box is true, then call to a function.
Someone can help me with that ?










share|improve this question






















  • What do you mean by Check Box? As in an input field checkbox?
    – GrandIQ
    Nov 22 at 20:44










  • A new feature that enable to create a clickable check box that return true or false on a click. I want to associate the check box to a function.
    – Ido Segal
    Nov 22 at 20:48










  • Are you trying to do this with HTML and Javascript? The google-sheets part is confusing me, does it need to relate to google-sheets or do you want an example of check boxes?
    – GrandIQ
    Nov 22 at 20:50














0












0








0







I want to use the "check box" operation of google sheets, and when the check box is true, then call to a function.
Someone can help me with that ?










share|improve this question













I want to use the "check box" operation of google sheets, and when the check box is true, then call to a function.
Someone can help me with that ?







javascript google-sheets






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 20:36









Ido Segal

254




254












  • What do you mean by Check Box? As in an input field checkbox?
    – GrandIQ
    Nov 22 at 20:44










  • A new feature that enable to create a clickable check box that return true or false on a click. I want to associate the check box to a function.
    – Ido Segal
    Nov 22 at 20:48










  • Are you trying to do this with HTML and Javascript? The google-sheets part is confusing me, does it need to relate to google-sheets or do you want an example of check boxes?
    – GrandIQ
    Nov 22 at 20:50


















  • What do you mean by Check Box? As in an input field checkbox?
    – GrandIQ
    Nov 22 at 20:44










  • A new feature that enable to create a clickable check box that return true or false on a click. I want to associate the check box to a function.
    – Ido Segal
    Nov 22 at 20:48










  • Are you trying to do this with HTML and Javascript? The google-sheets part is confusing me, does it need to relate to google-sheets or do you want an example of check boxes?
    – GrandIQ
    Nov 22 at 20:50
















What do you mean by Check Box? As in an input field checkbox?
– GrandIQ
Nov 22 at 20:44




What do you mean by Check Box? As in an input field checkbox?
– GrandIQ
Nov 22 at 20:44












A new feature that enable to create a clickable check box that return true or false on a click. I want to associate the check box to a function.
– Ido Segal
Nov 22 at 20:48




A new feature that enable to create a clickable check box that return true or false on a click. I want to associate the check box to a function.
– Ido Segal
Nov 22 at 20:48












Are you trying to do this with HTML and Javascript? The google-sheets part is confusing me, does it need to relate to google-sheets or do you want an example of check boxes?
– GrandIQ
Nov 22 at 20:50




Are you trying to do this with HTML and Javascript? The google-sheets part is confusing me, does it need to relate to google-sheets or do you want an example of check boxes?
– GrandIQ
Nov 22 at 20:50












2 Answers
2






active

oldest

votes


















1














While I'm unsure of exactly what you want to do in javascript, the Google Script editor may be useful for you.



In a Google Sheet, go to Tools > Script Editor. It should open a new page and create a new project with a blank function. This is where you can make new functions to be run within Google Sheets.



As an example I made a function called getSum:



function getSum(a,b) {
return a+b;
}


If you save this script and go back to Sheets, you can do =getSum(1,2) and it will return 3



If you wanted to integrate this with a Tick Box, you could do =IF(A1,getSum(1,2),getSum(2,2))



In this case, when the tick box is checked, it will run the first statement, and return 3 , when the box is unchecked, it will return 4



I'm not entirely sure on what you are trying to achieve with JavaScript, but this is one way to introduce custom functions (using Google Script).






share|improve this answer





















  • Thank you for the details, appreciate it!
    – Ido Segal
    Nov 22 at 23:30



















1














Supposing your checkbox is at A1, you could use this script to test when it's checked or unchecked (modified):



function onEdit(e) {
var range = e.range;
if (range.getA1Notation() == 'A1') {
var value = range.getValue();
range.setNote('Changed on ' + new Date() + ' to ' + range.getValue());
if (typeof value === 'boolean' && value == true) {
// Do something or call a function when the tick box is checked
}
}
}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437722%2fgoogle-sheets-using-javascript-functions-and-check-box%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    While I'm unsure of exactly what you want to do in javascript, the Google Script editor may be useful for you.



    In a Google Sheet, go to Tools > Script Editor. It should open a new page and create a new project with a blank function. This is where you can make new functions to be run within Google Sheets.



    As an example I made a function called getSum:



    function getSum(a,b) {
    return a+b;
    }


    If you save this script and go back to Sheets, you can do =getSum(1,2) and it will return 3



    If you wanted to integrate this with a Tick Box, you could do =IF(A1,getSum(1,2),getSum(2,2))



    In this case, when the tick box is checked, it will run the first statement, and return 3 , when the box is unchecked, it will return 4



    I'm not entirely sure on what you are trying to achieve with JavaScript, but this is one way to introduce custom functions (using Google Script).






    share|improve this answer





















    • Thank you for the details, appreciate it!
      – Ido Segal
      Nov 22 at 23:30
















    1














    While I'm unsure of exactly what you want to do in javascript, the Google Script editor may be useful for you.



    In a Google Sheet, go to Tools > Script Editor. It should open a new page and create a new project with a blank function. This is where you can make new functions to be run within Google Sheets.



    As an example I made a function called getSum:



    function getSum(a,b) {
    return a+b;
    }


    If you save this script and go back to Sheets, you can do =getSum(1,2) and it will return 3



    If you wanted to integrate this with a Tick Box, you could do =IF(A1,getSum(1,2),getSum(2,2))



    In this case, when the tick box is checked, it will run the first statement, and return 3 , when the box is unchecked, it will return 4



    I'm not entirely sure on what you are trying to achieve with JavaScript, but this is one way to introduce custom functions (using Google Script).






    share|improve this answer





















    • Thank you for the details, appreciate it!
      – Ido Segal
      Nov 22 at 23:30














    1












    1








    1






    While I'm unsure of exactly what you want to do in javascript, the Google Script editor may be useful for you.



    In a Google Sheet, go to Tools > Script Editor. It should open a new page and create a new project with a blank function. This is where you can make new functions to be run within Google Sheets.



    As an example I made a function called getSum:



    function getSum(a,b) {
    return a+b;
    }


    If you save this script and go back to Sheets, you can do =getSum(1,2) and it will return 3



    If you wanted to integrate this with a Tick Box, you could do =IF(A1,getSum(1,2),getSum(2,2))



    In this case, when the tick box is checked, it will run the first statement, and return 3 , when the box is unchecked, it will return 4



    I'm not entirely sure on what you are trying to achieve with JavaScript, but this is one way to introduce custom functions (using Google Script).






    share|improve this answer












    While I'm unsure of exactly what you want to do in javascript, the Google Script editor may be useful for you.



    In a Google Sheet, go to Tools > Script Editor. It should open a new page and create a new project with a blank function. This is where you can make new functions to be run within Google Sheets.



    As an example I made a function called getSum:



    function getSum(a,b) {
    return a+b;
    }


    If you save this script and go back to Sheets, you can do =getSum(1,2) and it will return 3



    If you wanted to integrate this with a Tick Box, you could do =IF(A1,getSum(1,2),getSum(2,2))



    In this case, when the tick box is checked, it will run the first statement, and return 3 , when the box is unchecked, it will return 4



    I'm not entirely sure on what you are trying to achieve with JavaScript, but this is one way to introduce custom functions (using Google Script).







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 22 at 21:18









    Adam Frank

    133




    133












    • Thank you for the details, appreciate it!
      – Ido Segal
      Nov 22 at 23:30


















    • Thank you for the details, appreciate it!
      – Ido Segal
      Nov 22 at 23:30
















    Thank you for the details, appreciate it!
    – Ido Segal
    Nov 22 at 23:30




    Thank you for the details, appreciate it!
    – Ido Segal
    Nov 22 at 23:30













    1














    Supposing your checkbox is at A1, you could use this script to test when it's checked or unchecked (modified):



    function onEdit(e) {
    var range = e.range;
    if (range.getA1Notation() == 'A1') {
    var value = range.getValue();
    range.setNote('Changed on ' + new Date() + ' to ' + range.getValue());
    if (typeof value === 'boolean' && value == true) {
    // Do something or call a function when the tick box is checked
    }
    }
    }





    share|improve this answer




























      1














      Supposing your checkbox is at A1, you could use this script to test when it's checked or unchecked (modified):



      function onEdit(e) {
      var range = e.range;
      if (range.getA1Notation() == 'A1') {
      var value = range.getValue();
      range.setNote('Changed on ' + new Date() + ' to ' + range.getValue());
      if (typeof value === 'boolean' && value == true) {
      // Do something or call a function when the tick box is checked
      }
      }
      }





      share|improve this answer


























        1












        1








        1






        Supposing your checkbox is at A1, you could use this script to test when it's checked or unchecked (modified):



        function onEdit(e) {
        var range = e.range;
        if (range.getA1Notation() == 'A1') {
        var value = range.getValue();
        range.setNote('Changed on ' + new Date() + ' to ' + range.getValue());
        if (typeof value === 'boolean' && value == true) {
        // Do something or call a function when the tick box is checked
        }
        }
        }





        share|improve this answer














        Supposing your checkbox is at A1, you could use this script to test when it's checked or unchecked (modified):



        function onEdit(e) {
        var range = e.range;
        if (range.getA1Notation() == 'A1') {
        var value = range.getValue();
        range.setNote('Changed on ' + new Date() + ' to ' + range.getValue());
        if (typeof value === 'boolean' && value == true) {
        // Do something or call a function when the tick box is checked
        }
        }
        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 at 21:53

























        answered Nov 22 at 21:12









        Flávio Toribio

        2,30532336




        2,30532336






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437722%2fgoogle-sheets-using-javascript-functions-and-check-box%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)