Question: JQuery:

```
        var Arr = new Array()
        var Selected = null;
        if ($('#chk').is(':checked')) {
            var List = $('#sellist option:selected');
            $.each(List, function(index, item) {
                Arr.push($(this).val());
            });
            Selected = Arr.join(',');
        }

```

I have to pass `Selected` as a json parameter.When check box is checked `Arr` is not null so code work fine but when `Arr` is null or empty i am unable to pass as a parameter. I use `""` instead of `null` but unable to solve the problem. How to handle this type of situation. Thanks.

Answer: 
This is easily a math problem. The distance between 2 points `(x1, y1)` and `(x2, y2)` can be calculated as follows:

![statement](https://i.stack.imgur.com/FFSBv.gif)

Simple Pythagoras. Query your database, point one is the point you want to find, point two is the one you get from the database, if the result of the above statement is smaller then the radius, it's in your range. (assuming all units match. You'll probably want to convert the lat/lon difference to km/whatever unit your radius is)

![graph](https://i.stack.imgur.com/OItPC.gif)
Note that if you want to have an accurate radius calculation for good ol' earth latitudes/longitudes, you'd have to use more complicated functions than the simple pythagorean distance mentioned in the accepted answer; look for "great circle distance", as e.g. posted [in another thread](https://stackoverflow.com/questions/5826430/great-circle-distance-formula-t-sql) already; however, for your purposes, the pythagorean distance should be close enough I guess; it delivers a reasonably good approximation, except if your latitude/longitude positions are somewhere near the poles.

And, just for completeness, your problem is actually not the opposite to the question "What locations are in a certain radius around my location?" - it's the exact same, only from the other direction - but since distance calculations are symmetric, it actually doesn't matter which direction you check!