If you are using php 5.2 or above for your development and haven't checked the function filter_var then you must check it.
With a greater functionality for filtering and validating your variables.
For eg. till then you must have used the regular expression to validate the email address. Here is how you can do it with filter_var function with 10X faster :
var_dump(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL));
So just check it out if you have not checked it yet:
http://in2.php.net/manual/en/function.filter-var.php
Lalit
Friday, February 12, 2010
Tuesday, February 2, 2010
Adding scrolling to div dynamically
Sometimes we need to add scrolling in a div element but we don't want to fix the height of the element initially.
That means...tag's height will be 0, but as soon as you fill the content of it through ajax etc. then you wish to add a scroll bar to it after reaching a specified height. How can we do that? Here is a simple solution:
You can made a Javascript function which will call after adding content to element.
function addScrollToDiv(){
var divHeight = document.getElementById("divid").offsetHeight;
if(divHeight > 250){
$('#divid').css({"height":"250px"});
$('#divid').css({"overflow":"auto"});
}else{
$('#divid').css({"height":""+divHeight+"px"});
}
}
That's it! How easy is it. Enjoy :)
function addScrollToDiv(){
var divHeight = document.getElementById("divid").offsetHeight;
if(divHeight > 250){
$('#divid').css({"height":"250px"});
$('#divid').css({"overflow":"auto"});
}else{
$('#divid').css({"height":""+divHeight+"px"});
}
}
That's it! How easy is it. Enjoy :)
Subscribe to:
Posts (Atom)