Archive for January, 2009
Create tinyurls in PHP using tinyurl.com API
For all those unfamiliar with tinyurl, it is a service thats lets you convert long urls into short ones. It is very popular and gets about 1.5 billion hits per month. Use of tinyurl can be seen hugely in applications like twitter. As twitter limits users to enter 140 character messages, long urls are a [...]
Read the rest of this entry >>
FAQ : How to toggle visibility of an html element by javascript
In my previous post, I discussed how we can change the style and/or css class of any html element by JavaScript. We can take advantage of this feature to add functionality where visibility of elements can be toggled. That means clicking a button will change the state of that element from visible to invisible and [...]
Read the rest of this entry >>
Setting style/css class of html elements from javascript
Style of an html element can be set in 2 ways.
Specify a css class name for the element.
Set the style inline for the element.
//Method 1:
<p class="boldText">Some text</p>
//Method 2:
<p style="font-weight:bold;">Some text</p>
Therefore using these 2 attributes we can change the style of any html element in the page. The only thing we need to do is get [...]
Read the rest of this entry >>
FAQ : Problem with javascript function parseInt
JavaScript function parseInt() is used to parse a string and extract the integer from that string.
Therefore if you do parseInt(”200xyz”), it will return 200.
The problem arises when you do the following:
var value = "010";
alert(parseInt(value)); // incorrect: will alert 8
You had expected 10 but what you got is 8.
Weird behavior, you must be thinking.
Actually not.It is [...]
Read the rest of this entry >>

