I’ve now created a jQuery plugin based on the howsecureismypassword code.
It can be found here: http://plugins.jquery.com/project/chronoStrength
I’ve now created a jQuery plugin based on the howsecureismypassword code.
It can be found here: http://plugins.jquery.com/project/chronoStrength
You will surely have seen one of these before:
Wouldn’t you rather have one that did this?
If the code is working properly (and there’s no reason it shouldn’t), the first option in the selection box will be the country you are currently in.
I suspect the vast majority of the time that anyone fills out such a form the person will be in the country they want to select. In those situations the person won’t have to make any changes, saving them a few seconds, and in any other situation they would just select their country as usual.
It’s a minor thing, but it’s one of those small things that could make filling out a form that little bit easier.
In case you’re interested the PHP code is below:
function find_country()
{
$ip=$_SERVER['REMOTE_ADDR'];
$country = '';
if (!empty($ip)) {
$country = file_get_contents('http://ip2.cc/?api=cname&ip='.$ip);
}
if ($country != "") { return $country; }
else { return "Please select your country"; }
}
A call to find_country() should be placed as the first option in a select input with the selected value set. It will either return the country name or the text “Please select your country” – that way if no result is returned the default option will still be helpful.
Note: The user will not always be in their home country, so make sure you give them the option of changing the country.
© Small Hadron Collider, 2010 · Contact Details