0

I know clicking an html <select> element will automatically show iOS's native selector. I want, however, to launch the selector from javascript with custom options. How can I do this?

Omar Meky
  • 596
  • 1
  • 5
  • 16
  • I don't understand what you're trying to accomplish. – ndugger Aug 06 '14 at 20:11
  • I'm basically wondering if Safari's JS API exposes a way to launch a native select list (in iOS) with custom options without the need to have a select element in the DOM. – Omar Meky Aug 06 '14 at 20:16
  • Why not just have a hidden select elem, and then trigger a click when you need it? – ndugger Aug 06 '14 at 20:20
  • Can you access options inside a hidden select element? That might work. – Omar Meky Aug 06 '14 at 20:21
  • I am not sure if this is possible. There are other answers for this on stackoverflow (http://stackoverflow.com/questions/16157459/how-to-open-select-element-using-jquery) but it states that it only works in certain browsers. Would it be possible to just dynamically load – morriswchris Aug 06 '14 at 20:21
  • I dunno, but you could hide it via CSS, instead of the hidden attribute – ndugger Aug 06 '14 at 20:21
  • @morriswchris I wanted to do it without having a select element in the DOM (or maybe hidden will work according to Nick) – Omar Meky Aug 06 '14 at 20:22
  • Not sure if it is possible without the select being fired through a DOM click. You could either use a hidden element like @Nick Dugger mentioned, or even style a visible select element to look like text/button/whatever you are trying to display using `background: transparent; border: 0; -webkit-appearance: none;` – morriswchris Aug 06 '14 at 20:25
  • I was about to get picky about it only affecting webkit, but his target is iOS, so that should work. also make the color transparent too, though. Also, may as well also set the opacity to 0, lol. Not sure if any of this will actually do what you want, though – ndugger Aug 06 '14 at 20:26
  • alright, will try out ... ideally the solution would support android as well – Omar Meky Aug 06 '14 at 20:27

0 Answers0