jQuery dropdown select on iPhones

This error had been driving me crazy for a few weeks – iPhone users were unable to submit new definitions on Hackterms. The culprit was hard to track down, because (1) I don’t own an iPhone and (2) there’s no way to console log. However, I finally sat down and figure it out.

To display error messages, I added a little flashing error message box right in the New Definition modal.

The culprit was some rogue jQuery (is there any other kind?) I was doing some routine validation to check if a user selected a category from a dropdown, and this line would not run on iPhones:


This ran just fine on Android and desktops, but not on iPhones. The solution was simple, once I zeroed in on it (read – found the right StackOverflow thread): a vanilla JS replacement worked just fine:

var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].value;

Now iPhone users can use my site 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s