Forum Moderators: open

Message Too Old, No Replies

alert inside drop down

         

hoju312

5:04 pm on Jun 23, 2006 (gmt 0)

10+ Year Member



Is it possible to have an alert on a certain option within a dropdown? I've tried everything I can think of, but the best I can do is an onChange alert.

rocknbil

5:51 pm on Jun 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard hoju!

I think you will still need to use onChange.

<select name="test" id="test" onChange="checkSel(this);">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>

function checkSel(obj) {
var ind = obj.selectedIndex;
if (ind == 1) { alert('You selected number two.'); }
}

(Remember item #1 in the list is index 0.) Untested, but that should do it . . . .