javascript - On dropdown menu option selection show some cells in the table -


i create web page, 2 dropdown menus, , table. better understanding create this. first dropdown menu display years, second country names. when select 1 of years or 1 of country names, in table should shown coins issued in year or country.

i looking question on internet, , have found this:

<script type="text/javascript"> <!--     function toggle_visibility(id) {        var e = document.getelementbyid(id);        if(e.style.display == 'block')           e.style.display = 'none';        else           e.style.display = 'block';     } //--> </script>  <a href="#" onclick="toggle_visibility('foo');">click here toggle visibility of element #foo</a> <div id="foo">this foo</div> 

i thought, give more "id" same tag in table able select both dropdown menus , other cells somehow hide, found out, can't add more "id". not know, how achive when select of options, selected group of coins shown in table.

any suggestions, how should solve problem?

thanks in advance.

you can use classes instead of ids. instead of id="foo" have class="foo".

the selector be(for single element) document.queryselector(".foo").

function toggle_visibility(selector) {    var e = document.queryselector(selector);    if(e.style.display == 'block')       e.style.display = 'none';    else       e.style.display = 'block'; } 

this expanded hide/show group of elements using document.queryselectorall

example here: http://jsfiddle.net/86c93ao6/


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -