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

    PC v MAC webdialog populate

    Scheduled Pinned Locked Moved Developers' Forum
    45 Posts 4 Posters 6.5k 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      Thomthom - thanks for the example - so it appears that the embedded js solution works consistently but the ruby run-script with .setAttribute() etc doesn't - it's weird ?
      I have tested it on my PC and it needed a tweak to do what I actually wanted - here's a version that sets only the first nested checkbox checked when the main one is checked [they all become enabled] - the other two nested checkboxes remain unchecked until you click on them - on unchecking the main one all of the nested ones are unchecked and disabled as required...

      <html>
      <head>
        <title>Checkbox Test</title>
        <script type="text/javascript">
      
      window.onload = init;
      
      function $(id)
      {
        return document.getElementById(id);
      }
      
      function init()
      {
        $('ch1').onclick = function()
        {
          $('ch2').checked = this.checked;
          if (!this.checked)
            val = this.checked
          else
            val = !this.checked
          $('ch3').checked = val;
          $('ch4').checked = val;
          $('ch2').disabled = !this.checked;
          $('ch3').disabled = !this.checked;
          $('ch4').disabled = !this.checked;
        };
      }
      
        </script>
      </head>
      <body>
      
      <p>
      <label for="ch1">Checkbox 1</label>
      <input type="checkbox" id="ch1" />
      </p>
      
      <fieldset>
       
        <p>
        <label for="ch2">Checkbox 2</label>
        <input type="checkbox" id="ch2" disabled="disabled" />
        </p>
       
        <p>
        <label for="ch3">Checkbox 3</label>
        <input type="checkbox" id="ch3" disabled="disabled" />
        </p>
       
        <p>
        <label for="ch4">Checkbox 4</label>
        <input type="checkbox" id="ch4" disabled="disabled" />
        </p>
       
      </fieldset>
      
      </body>
      </html>
      
      

      All it needs now is some auto-value setting when a checkbox is changed so that these can be read out into Sketchup when needed... πŸ€“

      TIG

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

        @tig said:

        Thomthom - thanks for the example - so it appears that the embedded js solution works consistently but the ruby run-script with .setAttribute() etc doesn't - it's weird ?

        Your Ruby script calls a JS method that use setAttribute?
        Why not just .checked ? I didn't try setAttribute at all, as checked seemed to work on all platforms.

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

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

          @tig said:

          All it needs now is some auto-value setting when a checkbox is changed so that these can be read out into Sketchup when needed... πŸ€“

          
            // Make all checkbox's values reflect their checked state.
            var inputs = document.getElementsByTagName('input');
            for ( i=0; i < inputs.length; i++ )
            {
              input = inputs[i];
              if ( input.getAttribute('type') == 'checkbox' )
              {
                input.onchange = update_checkbox;
                input.onclick = update_checkbox; // for IE
                input.onkeyup = update_checkbox; // for IE
              }
            }
          }
          
          function update_checkbox()
          {
            this.value = this.checked.toString();
            this.title = this.checked.toString();
          }
          
          

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

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

            hm.... that did not work under IE...

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

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

              Updated the post.

              That should work.

              NOTE! the onChange event triggers in IE when the input looses focus - so I attached the same event handler to onClick and onKeyUp to force immediate update. But if you use the this snippet with the other example the two onClick events will override each other and only one will trigger. You'd need to attach the event instead to make both event handlers work.

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

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

              Advertisement