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

    Is there a <select equivalent for <input onClick?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 5 Posters 588 Views 5 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.
    • sdmitchS Offline
      sdmitch
      last edited by

      "<input ... onClick=" sends info to a designated call back routine. Is there an equivalent that can be used in a <select that would trigger when the selection changes.

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

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Like SelectionObserver ?

        TIG

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          I think he means an html select element.

          http://msdn.microsoft.com/en-us/library/ie/ms536967%28v=vs.85%29.aspx
          http://stackoverflow.com/questions/647282/is-there-an-onselect-event-or-equivalent-for-html-select

          Hi

          1 Reply Last reply Reply Quote 0
          • jiminy-billy-bobJ Offline
            jiminy-billy-bob
            last edited by

            http://api.jquery.com/change/ ?

            25% off Skatter for SketchUcation Premium Members

            1 Reply Last reply Reply Quote 0
            • sdmitchS Offline
              sdmitch
              last edited by

              @jim said:

              I think he means an html select element.

              http://msdn.microsoft.com/en-us/library/ie/ms536967%28v=vs.85%29.aspx
              http://stackoverflow.com/questions/647282/is-there-an-onselect-event-or-equivalent-for-html-select

              Yes, exactly. Now if I can just figure out how to "Trigger the handler".

              If anyone has any ideas on how to make this work in Sketchup, please pass them along.

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

              http://sdmitch.blogspot.com/

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

                @sdmitch said:

                Yes, exactly. Now if I can just figure out how to "Trigger the handler".

                The better page for more info on the Select element is here:
                http://msdn.microsoft.com/en-us/library/ms535893(v=vs.85).aspx

                There are several ways to fire the onselect event:

                Assume that "droplist" is the id for your select element.
                %(#8000BF)[dlist = document.getElementById("droplist");]

                Set the selected index to the third option, on the select element:
                %(#8000BF)[dlist.selectedIndex=2;]

                Call the %(#8000BF)[click()] method on a specific option element by it's id:
                %(#8000BF)[opt_green = document.getElementById("option_green"); opt_green.click();]

                Call the %(#8000BF)[click()] method on a option element by it's index:
                %(#8000BF)[opts = dlist.childNodes(); if opts.length > 0 { opts[2].click(); } else { \\ handle empty array }]

                PC also has the %(#8000BF)[fireEvent()] method, but you probably should stay away from platform dependant methods.

                💭

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • sdmitchS Offline
                  sdmitch
                  last edited by

                  Thanks much Dan for the info. Looking back at by previous posts, I see that I never made it clear that the question is relative to a WebDialog associated with a plugin. Don't know if that matters but just so you know.

                  Eureka I have found it. It was all a matter of where the onChange was. Because the onClick was part of each radio button statement, I assumed it was the same with the select list. Instead it just needed to be in the <select> statement itself. Thanks again to one and all for the links that put me on the right path to find the answer.

                  def showme()
                    @dlg=UI;;WebDialog.new("VerySimple", true,"Test",500,300,10,10,true)
                    @dlg.set_html(
                      "<html>
                        <body>
                          <form>
                            <select onChange='tellSketchup(value)'>
                              <option value='option1' >Option 1</option>
                              <option value='option2' >Option 2</option>
                            </select> ; Head Type<br><br>
                          </form>
                          <script type='text/javascript'>
                            function tellSketchup(value)
                            {
                                window.location='skp;OptionChanged@'+value;
                            }
                          </script>
                        </body>
                      </html>"
                      )
                    @dlg.show {} #show it 
                          
                    @dlg.add_action_callback("OptionChanged") {|d,p|
                      puts "OptionChanged value=#{p}"
                    }
                  end
                  
                  
                  

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

                  http://sdmitch.blogspot.com/

                  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