Javascript isn't a huge fan of responsive design. If you insist on using JS to change elements when a page is mobile vs desktop, you'll have to watch the window size and act accordingly on resize events.
That said, this might help - htmlgoodies.com/beyond/javascript/convert-a-list-…
The "normal" way would be to have a media query, show the dropdown or list based on the device width and then use JS to act accordingly to send the input to whatever. You'll still need to check which element is visible when the list is clicked or the form is submitted, but you'll check it once (on submit for example) and not every time the device changes it's width.