• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

How to Use datalist in sketchup webdialog box

Scheduled Pinned Locked Moved Dynamic Components
sketchup
6 Posts 4 Posters 2.9k Views
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.
  • R Offline
    rnpatel9789
    last edited by 16 Nov 2015, 13:57

    Hello Everyone,

         I just want to use HTML datalist inside the sketchup webdialog box window if anyone have any idea how to use it please help me.
    
    1 Reply Last reply Reply Quote 0
    • K Offline
      kaas
      last edited by 16 Nov 2015, 14:37

      More (visual) info is needed I think. What kind of datalist? What should it look like in the webdialog? What kind of actions must a user be able to do? etc etc.

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdmitch
        last edited by 16 Nov 2015, 16:33

        @rnpatel9789 said:

        Hello Everyone,

             I just want to use HTML datalist inside the sketchup webdialog box window if anyone have any idea how to use it please help me.
        

        Perhaps something like this

        dataarray = ['a', 'b', 'c', 'd']; datalist = ""
        dataarray.each{ |d| 
        	datalist += "<option value='"+d+"' >"+d+"</option>" 
        }
        dlg = UI;;WebDialog.new("Dummy", false,"dummy",200,200,10,10,true)
        html = <<-HTML
        <body>
         Selection;<select id='list'>#{datalist}</select><br><br>
        </body>
        HTML
        dlg.set_html(html)
        dlg.show
        
        

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • R Offline
          rnpatel9789
          last edited by 21 Nov 2015, 11:39

          hi sdmitch,

          I doing something like what you posted but not with selection rather with input field to add behaviour something like autofill in search box. I am using a specific HTML file for the webdialog window and using javascript function to fill the data into the datalist. But In my case it seems the ".inner_html" in not working. I don't know what is the reason may sketchup is not supporting or something else.

          Here's code sample:

          In javascript:

          function setData(projectnos, roomnames){
          proj_no = projectnos.split(",");
          var options = '';
          for(var i = 0; i < proj_no.length; i++)
          options += '<option value="'+proj_no[i]+'" />';
          document.getElementById('proj').innerHTML = options;
          }

          In HTML:

          <input type="text" name="ProjectNumber" list="proj" />
          <datalist id="proj">
          <option value="001"/>
          </datalist>

          If you have some solution for this then please help me it's very helpful for me.

          Thank you

          1 Reply Last reply Reply Quote 0
          • K Offline
            kaas
            last edited by 21 Nov 2015, 11:53

            Your html & javacript code is not valid.
            The for-loops should have beginning and closing brackets.
            The options have a value but no content.

            Look for the complete syntax here:
            http://www.w3schools.com/js/js_loop_for.asp
            http://www.w3schools.com/tags/tag_option.asp

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by 22 Nov 2015, 12:47

              innerHTML gives you the tags, as well as text content, that you probably don't want...

                          <script>
                                  function showNew(key,val) {
                                  (key).textContent=(val).value;
                                  }
                                  </script>
              

              john

              learn from the mistakes of others, you may not live long enough to make them all yourself...

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

              Advertisement