Javascript – Round numbers to some decimal places
Posted by Imran in Javascript on June 30th, 2009
Javascript’s Math.round function allows a user to round a float to an integer. But most of the time we need some function that’ll let us round the number to any decimal places we want. So here is the function that’ll solve your problem:
function roundNumber(num,decimal){
var numerator = Math.round(num * Math.pow(10, decimal));
[...]
Javascript Beginners – Select a dropdown option by value
Posted by Imran in Javascript on June 27th, 2009
A very simple and common issue a Javascript newbie often faces is how to select a dropdown option dynamically by value. People who are working for long with Javascript would solve it in minutes, but hey, this is for a newbie, remember?
So this is a simple function I wrote to do the work.
[...]
Mysql function to find distance between two places using lat/long
Posted by Imran in Google Map, Mysql on June 24th, 2009
Sometimes we need to find out list of places that are within a certain radius from a center place where coordinates of the places are saved in the database. Now we have 2 solutions for this – either loop through all the places find the distance from the center point and keep the places that [...]
Use multiple database connections in Zencart
There are times when you may need to grab data from a database outside the Zencart database, it may be the case when two zencart installation need to share data or may be some other reasons. To achieve this, you need to open 2 database connections that wont overlap each others. People generally open the [...]
Google Geocoding Service – get latitude, longitude from address, postcode
Posted by Imran in Google Map on June 11th, 2009
Google has a very handy web service available for geocoding. Very often we require to know the longitude, latitude of a postcode, may be for finding distance between 2 places or any other reasons (who cares) and as always, Google is ready with the service before you realize you’ll need that . This is [...]
Practice writing clean and simple code
Posted by Imran in Programming on June 1st, 2009
I remember the 1st year school days in SUST when I started writing code in pascal. A simple prime number generation program lasted in 100 lines script , I added and I commented off, and finally when the script is ready, I used to find 70% code that are commented off. That was a [...]
Where to check if PHP mail() function is not working
Lots of time we find php mail() function is not working. In some cases, the email is not sent even the function returns true. Following are the points you may check while debugging:
First check if the sendmail_path variable is set properly. You can see it from echo – ing phpinfo() in a page. The typical [...]
How to add new sidebox in Zencart
A very common question comes into mind of zencart freshers is how they can add a new sidebox with their own content. It might be new banners, or may be a custom newsletter section or may be a google ad. People search the codes like crazy and again ends up adding some hard-coded html/php garbage [...]
Debug old IE versions in a single tool
Posted by Imran in Browser Compatibility on May 21st, 2009
Internet Explorer is always a pain in the arse for web developers. One new release and one additional pain. Worst part is it is difficult to debug in all the version in a single machine. At last Microsoft has shown some brain in IE8 by adding IE7 compatibility mode and a developers tool. Despite of [...]
