-1

This is working fine in Internet Explorer and Firefox but not working in Chrome browser

<select name="Consolidate Report" class="input">
    <option value="">Consolidate Report</option>
    <option value="" onclick="view_graph()">View Graph</option>
    <option value="" onclick="export_graph()">Export Excel</option>
</select>
krlzlx
  • 5,752
  • 14
  • 47
  • 55
  • just show your `view_graph` function..you have an error on `view_graph` function..so it won't alow to execute the function..just only returns `function is not defined` – Janen R Jun 09 '17 at 06:33
  • 2
    Possible duplicate of [onclick on option tag not working on IE and chrome](https://stackoverflow.com/questions/9972280/onclick-on-option-tag-not-working-on-ie-and-chrome) – XYZ Jun 09 '17 at 06:37

3 Answers3

0

<option> elements don't fire the click event in most browsers. you can go with onchange event for select.

http://webbugtrack.blogspot.in/2007/11/bug-280-lack-of-events-for-options.html

How to use onClick() or onSelect() on option tag in a JSP page?

Ahmed Ginani
  • 6,522
  • 2
  • 15
  • 33
0

I have another suggestion

<select onchange="valueChanged(this.value);" name="Consolidate Report" class="input">
        <option value="">Consolidate Report</option>
        <option value="view_graph" >View Graph</option>
        <option value="export_graph">Export Excel</option>
 </select>

        <script> 

         function valueChanged(value){

            if(value == 'view_graph')
            {
                alert('view_graph');
            }else if(value == 'export_graph')
            {
                alert('export_graph');
            }
          }
        </script>
Arun
  • 1,609
  • 1
  • 15
  • 18
0

Use onchange() for <select></select> tag instead of onclick().

function view_graph(val){
alert(val);
}
<select name="Consolidate Report" class="input" id="x" onchange="view_graph(this.value)">
   <option value="0">--Select--</option>
    <option value="report">Consolidate Report</option>
    <option value="graph">View Graph</option>
    <option value="excel">Export Excel</option>
</select>
J.Joseph
  • 234
  • 2
  • 11