Show/hide data lines and columns in google chart (remove column onclick/toogle multiple checkboxes/labels)

How to show and hide lines data in standart google chart?
Example of chart build:

google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
    var data = google.visualization.arrayToDataTable([
        ['Year', 'Sales', 'Expenses'],
        ['2013', 1000, 400],
        ['2014', 1170, 460],
        ['2015', 660, 1120],
        ['2016', 1030, 540]
    ]);

    var columns = [];
    var series = {};
    for (var i = 0; i < data.getNumberOfColumns(); i++) {
        columns.push(i);
        if (i > 0) {
            series[i - 1] = {};
        }
    }

    var options = {
        title: 'Chart title',
        vAxis: {minValue: 0},
        tooltip: {trigger: 'selection'},
        aggregationTarget: 'category',
        series: series
    };

    var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
    chart.draw(data, options);

    google.visualization.events.addListener(chart, 'select', function () {
        var sel = chart.getSelection();
        if (sel.length > 0) {
            if (sel[0].row === null) {
                var col = sel[0].column;
                if (columns[col] == col) {
                    columns[col] = {
                        label: data.getColumnLabel(col),
                        type: data.getColumnType(col),
                        calc: function () {
                            return null;
                        }
                    };
                    series[col - 1].color = '#CCCCCC';
                }
                else {
                    columns[col] = col;
                    series[col - 1].color = null;
                }
                var view = new google.visualization.DataView(data);
                view.setColumns(columns);
                chart.draw(view, options);
            }
        }
    });
}

JQuery (javascript) On selectlist change – get selected/current value and do some action

If you have form with select list

    <form name="exampleform" action="index.php" method="POST">
        <select name="myselect" id="myselectid">
            <option value="apple">Apple</option>
            <option value="banana">Banana</option>
            <option value="melon">Melon</option>
        </select>
    </form>

and you need to do some action when user change/select some items in select list then you can use this construction:

    $("#myselectid").change(function () {
            var user_selected = $(this).val();
            console.log('User selected value: ' + user_selected);
    });

Event when javascript opened/popup window is closed

If you need check if the popup window was closed by javscript, you can use this ↓

<script type="text/javascript">
function open_popup(url)
{
     var popup = window.open(url, "", "width=450,height=250,resizable=yes,scrollbars=yes,status=yes");
    var windowCheckInterval = setInterval(function() { windowCheck(); }, 350);
        // Check function
        function windowCheck() {
            if (!popup || popup.closed) {
                clearInterval(windowCheckInterval);
		alert('popup window closed');
            }
        }
}
</script>

and ↓

<a onclick="open_popup('http://www.google.com');" href="#" >
   Open google in popup window
</a>

How to validate email address in JavaScript?

The best way is using regular expressions.
Example ↓

<script type="text/javascript">
function isValidEmail(email) {
    var regex_pattern = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return regex_pattern.test(email);
}
</script>

Also you can use some another reg.exps:

Continue reading How to validate email address in JavaScript?