sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Get_element value for checkbox

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 4 Posters 805 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      what is the value it returns?

      I'm not quite sure, but...
      checkbox values are a bit quirky crossbrowsers - might need some help of a javascript to determine the state and return a corresponding value.

      But knowing the return value you get from .get_element_value will help.

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • Q Offline
        Qverburg
        last edited by

        @@testwindow.get_element_value("test") on @@testwindow.get_element_value("test") on

        first one is with checkbox checked, second one without ckeckbox checked......

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          This page might be of use: http://www.quirksmode.org/js/forms.html#scheckbox
          I do have a suspicion that checkboxes doesn't report a value that reflect the checked state. So you might want to make a JS function that reads the checked state of the checkbox and put it into a hidden input field.

          so you first call that JS script using .execute_script - giving the JS function the element id as argument. then read the value of the hidden input field.

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • Q Offline
            Qverburg
            last edited by

            Great idea!
            Thanks for your helpfull and quick responses πŸ˜„

            1 Reply Last reply Reply Quote 0
            • P Offline
              Pout
              last edited by

              or maybe like this

              1. ruby
              command = "_getcheckboxvalue()"
              webdialog.execute_script(command)
              
              1. javascript
              function _getcheckboxvalue(){
              //get the checkboxvalue
              thevalue=document.getElementById('test').value;
              //send it back to ruby
              query = 'skp;_sendcheckboxvalue@'+thevalue;
              window.location.href = query;
              }
              

              3.ruby

              webdialog.add_action_callback("_sendcheckboxvalue") {|webdialog,p|
              //p=the checkbox value
              //do something
              }
              

              (untested)

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                The reason why I didn't use .add_action_callback calling back from JS to Ruby is that the amount of data might be limited and there are OSX issues with JS to Ruby callbacks.

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • Q Offline
                  Qverburg
                  last edited by

                  Hmm this is strange.

                  When I try to get the checkbox value in the javascript, it's again always on.
                  The hidden textbox method also doesn't work because I can't seem to set the textbox value. (and if I could, the checkbox would say its always on....)

                  Any ideas?

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    In regard to the checkbox value - did you read my link?

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • Q Offline
                      Qverburg
                      last edited by

                      @thomthom said:

                      In regard to the checkbox value - did you read my link?

                      Yes I did thank you for that. Played with it for 2 hours but couldn't manage to read the checkbox values in that manner.
                      The only thing that worked was the getElementById but it still reports the checkbox as on when its not.

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        You might just try and keep the state of the control in your own Js variable, and then use onclick or onchange events to toggle the variable ON/OFF value.

                        I do it for 'toggle buttons' such as buttons that collapse / uncollapse a <DIV>.

                        I'm not here much anymore.

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement