Is it possible to see what the index is of a Select combobox selection?

I have website with a select box which has a few hundred options.

<select name="breed" id="breed">
<option value="">Please select</option>
<option value="Abyssinian" >Cat: Abyssinian</option>
<option value="American Bobtail" >Cat: American Bobtail</option>
<option value="Mixed (Unknown)" >Cat: Mixed (Unknown)</option>

....

<option value="Mioritic Sheepdog" >Dog: Mioritic Sheepdog</option>
<option value="Mixed (Unknown)" >Dog: Mixed (Unknown)</option>

....

</select>

My problem is that the "Cat: Mixed (Unknown)" and the "Dog: Mixed (Unknown)" both return the same option value.

Is it possible to get the index number of the selected item?

Cheers,

Dave

Change the value of the option

<option value="Cat Mixed (Unknown)" >Cat: Mixed (Unknown)</option>
....
<option value="Dog Mixed (Unknown)" >Dog: Mixed (Unknown)</option>

Thanks Jorge, that was exactly what I was after.

@albucurus, yes, that would be the obvious thing. However, it's not my site and I'm reluctant to tinker with it.

You can get the index of the selected option using javascript

var index = document.getElementById("breed").selectedIndex;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.