Highlight Search Words
Sep 28, 2009 Php
With the temperature up on keywords and searches, many sites have opted for highlighting the keywords from their searches. This can be useful for quickly finding relavant words withing large pages of text. It can also be quite annoying as the highlighted colors are usually hot pink, lime green or yellow, like highlighter marker pens after which the process was named.
Read the rest of this entry »
Validate Date Using PHP
Sep 28, 2009 Php
PHP provides many date manipulation devices and an entire suite of date functionality with the datetime class. However, this does not address date validation, that is, what format a date is received in. The PHP strtotime() function will accept many forms of dates in most human readable strings. The issue with strtotime is that there is no way to account for differing date formats, eg: 12/05/2010. Depending on what country a user is from, this date could have several meanings, such as which is the month, and which is day field. By splitting the date into its respective fields, each segment can be checked with the PHP checkdate function. The function below validates a date by splitting the date in year, month, day and using these as arguments to checkdate.
Read the rest of this entry »
How can submit form without submit button ?
Sep 18, 2009 Javascript
We can submit a form by javascript using 2 ways following code:
1.document.formname.submit();
2.document.getElementById(formid).submit();
You can use both ways to submit a form but document.getElementById(formid).submit() is most effective because it always works but document.formname.submit() gives error some times , you will try to find out the mistake but you will not get anything.
So i prefer document.getElementById(formid).submit()
Difference between htmlentities( ) and htmlspecialchars( ) ?
Sep 18, 2009 Html
Both are predefined function of php.
htmlentities() — Convert all applicable characters to HTML entities.
<?php
$str = “A ‘quote’ is <b>bold</b>”;
// Outputs: A ‘quote’ is <b>bold</b>
echo htmlentities($str);
?>
and
htmlspecialchars() — Convert special characters to HTML entities.
<?php
$new = htmlspecialchars(”<a href=’test’>Test</a>”, ENT_QUOTES);
echo $new; // <a href='test'>Test</a>
?>
Special charachers are :
=> ‘&’ (ampersand)
=> ‘”‘ (double quote)
=> ”’ (single quote)
=> ‘<’ (less than)
=> ‘>’ (greater than)
What onreadystatechange event of ajax ?
Sep 18, 2009 Ajax
0: uninitialized
Open request has not been called yet.
1:loading
Send request has not been called yet.
2:loaded
send request has been called,but the response is yet not availble.
3: interactive
The response is being downloaded ,and ther responseText property holds
partial data.
4:completed
The response has been loaded and the request is completed.
