Saturday, January 29, 2011

disable form element using jquery

Using Id:

jQuery('#id').attr('disabled','disabled'); //Here id is form element id
//Enable the form element
jQuery('#id').removeAttr("disabled");

Using Name:

jQuery('input[name="elementname"]').attr('disabled','disabled'); //Here element name is form element name
//Enable the form element
jQuery('input[name="elementname"]').removeAttr('disabled');

Saturday, January 22, 2011

get the text box value using jquery

By using textboxid:
jQuery('#texboxid').val();

By using name:
jQuery('input[name="textboxname"]').val();

Saturday, January 15, 2011

get second of the current time using date function in php

$second = date("s");

get number of days between two given dates using MySQL

SELECT DATEDIFF( "2007-03-07", "2007-03-01" )

Difference between include and require

require(): It will cause a fatal error and halt the execution of the script if the file not found.
include(): If the file not found a warning will be issued, but execution will continue.

get number of records count in mysql

SELECT COUNT('fieldname') AS numcount FROM tablename;
//Instead of using COUNT(*) it is good i think

AJAX full form

Asynchronous JavaScript and XML

find the current date using MySQL

SELECT now();
or
SELECT CURDATE();
or
SELECT CURRENT_DATE();

submit a form without submit button

document.formname.submit(); //It will work when we are using single form in a page

document.forms['formname'].submit(); //It will work when we are using multiple forms

// above formname is our formname

submit a form using javascript

document.formname.submit(); //It will work when we are using single form in a page

document.forms['formname'].submit(); //It will work when we are using multiple forms

// above formname is our formname

maximum length of a database name, table name, field name in MySQL

Database name: 64 characters
Table name: 64 characters
Column name: 64 characters