3

I met an error when i use chrome (it's ok in firefox). It's my code, very simple:

<html><head></head>
<body>
<select>
        <option onclick="alert('abc');">A</option>
        <option>B</option>
</select>         
</body>
</html>

In firefox, when i click on option A, it will be show an alert('abc'). But in chrome, it doesn't run. Can i change something in setting of chrome?

Any suggestions?

Thanks!!!

Trong Lam Phan
  • 2,292
  • 3
  • 24
  • 51

2 Answers2

2

use onchange event provided by html select,

Example : alerts the selected option

<select onchange="alert(this.value)">
        <option>A</option>
        <option>B</option>
</select>
user183781
  • 31
  • 5
1

You need to use the onchange event

http://jsfiddle.net/WB3Q9/

When a user selects an option, the value of the select element changes, thus firing the onchange event and whatever function you binded to it

<select onchange="alert('The Value is ' + this.value)">

Zone6
  • 314
  • 2
  • 4