Is there a <select equivalent for <input onClick?
-
"<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.
-
Like
SelectionObserver? -
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 -
-
@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-selectYes, 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.
-
@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).aspxThere 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.
-
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement