views:

279

answers:

1

I'm building a mobile website. I use regular html for the dropdown like below. If I select the dropdown on Android and click on "Category", it tries to submit the form. But iPhone doesn't do anything which is the desired behavior I want. I found a similar post here, but I'm not building an app. Some websites use links instead of dropdown, but it's not an option for me. Any suggestion or way around it? Thanks!

<select onchange="document.form.submit();">
   <option>Category</option>
   <option value="1">1</option>
   <option value="2">2</option>
</select>
+1  A: 

I would recommend revising your logic to not submit on change if that isn't your desired behavior. You may want to make a function that inspects the selected option on change before submit to decide whether or not to submit.

Something like below..

<select onchange="dropDownChange(this);">
   <option>Category</option>
   <option value="1">1</option>
   <option value="2">2</option>
</select>

function dropDownChange(element){
    if(element.selectedIndex != 0){
        document.form.submit();
    }
}
Quintin Robinson