Saturday, August 7, 2010

jQuery - Get the element Title value of a clicked item

Like the previous post you can get the title value of a element easily as well.

$('.clsname').click(function(){
     var idval = this.title;
});

jQuery - Get the element ID value of a clicked item

This is small tip that I found useful when completing a new project. As usual with jQuery everything is simple as 1 2 3

$('.clsname').click(function(){
     var idval = this.id;
});

Sunday, August 1, 2010

php post content-length exceeds - post_max_size

1) If you have access to the php.ini file there is a easy fix, just edit the post_max_size line with a higher value you want.

2) If you do not have access to the php.ini file you can create a text file and name it as php.ini (remember to check if the file extension is .ini not .txt) and put this line inside:
post_max_size = 15M
save and upload to the folder where your php script is placed.

(I have used 15M, you can put any value you want)

It is also better to have a chat with your hosting technical help team.

Saturday, July 31, 2010

How to loop through a php assoative array

Looping through a php assoative array is really easy with foreach loop.

<?php

$array = array ("Fruit" => "Apple", "Animal" => "Dog", "Number" => 1, "Name" => "Jhon" );

foreach($array as $key => $value)
{
    echo $key.': '.$value;
    echo '<br />';
}

/* result

Fruit: Apple
Animal: Dog
Number: 1
Name: Jhon

*/

?>

Thursday, July 29, 2010

jquery datepicker with current date and custom date format

I searched the net to find a more simpler solution to set the current date with jQuery UI datepicker but didn't find anything. So here is the solution I used. Mixture of both normal JavaScript and jQuery. You can also check out how to use a custom date format with jQuery UI datepicker.

var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var d = year + "-" + month + "-" + day;

$('.date-pick').datepicker({ dateFormat: 'yy-mm-dd' }).val(d);

Wednesday, July 21, 2010

How to get number of characters of a String in php - strlen()

You can use strlen() to easily find the length of an php string.

<?php
$str = 'Hello World';
echo strlen($str); // 11
?>

Many new php developers make the mistake of using count() which is used to count elements in an array or properties in an object.

Saturday, July 17, 2010

Get Select Box Value - jQuery Tip

It is easy as 1,2,3 with jQuery :)

$('#selectbox').val()

Lets see how to write this with on change event

$('#selectbox').change(function(){
     alert($(this).val());
});

Lets see how to get the selected text (not the value)

$('#selectbox').change(function(){
     alert($('#selectbox :selected').text());
});

Thursday, June 10, 2010

wamp www root index.php file got deleted

I accidentally delete the default www root folder index.php for WAMP server all the time. So I keep a back up of the index.php
I uploaded my index.php if you want to restore.

http://www.mediafire.com/?yhdt1tz2cjn