• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Is there a <select equivalent for <input onClick?

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 5 Posters 586 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.
  • S Offline
    sdmitch
    last edited by 25 Apr 2014, 20:27

    "<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
    • T Offline
      TIG Moderator
      last edited by 25 Apr 2014, 20:56

      Like SelectionObserver ?

      TIG

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by 25 Apr 2014, 21:24

        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
        • J Offline
          jiminy-billy-bob
          last edited by 25 Apr 2014, 21:44

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

          25% off Skatter for SketchUcation Premium Members

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdmitch
            last edited by 26 Apr 2014, 11:31

            @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
            • D Offline
              Dan Rathbun
              last edited by 27 Apr 2014, 01:28

              @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
              • S Offline
                sdmitch
                last edited by 27 Apr 2014, 13:42

                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
                1 / 1
                • First post
                  1/7
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement