We can overwrite default java script function by using the following way: For example overwrite alert function
function alert(msg) {
console.info(msg);
}
Web Development Information [PHP, DRUPAL, MYSQL, MAGENTO, JQUERY, JAVASCRIPT, CSS, HTML5]
Friday, December 28, 2012
Monday, May 14, 2012
HTML5 Range Control
This is the another input type introduced in HTML5 control is range. Its acting like volume or percentage. Your can drag the point and set the value.
0<input type="range" name="percentage" value="0" oninput="x.value=parseInt(percentage.value)" /><output name="x">0</output>
HTML5 Input Controls: Advanced Controls
Date list option in HTML5. Its used for auto complete text field. Your values given in datalist tag. These values are linked with list="browsers"
Browser: <input name="browsers" list="browsers" required="required" />
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
Browser: <input name="browsers" list="browsers" required="required" />
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
HTML5 Input Controls
<form method="post">
Email: <input type="email" name="email" value="" required="required">
URL: <input type="url" name="url" value="" required="required">
Telephone: <input type="tel" name="tel" value="" required="required">
<input type="submit" value="Submit" />
</form>
The above controls are introduced in HTML5 input controls. If we omit required attributes, it may be empty. Validation also will happen while submit a form.
Thursday, April 5, 2012
CASE WHEN option in MySQL
MySQL will return conditional based values without using if condition. Without using if conditions, we can use CASE WHEN option in MySQL.
For example,
For example,
For example: table name: students
sno | name | mark |
---|---|---|
1 | Sachin | 39 |
2 | Dravid | 90 |
3 | Kohli | 30 |
4 | Ganguly | 66 |
Output: Pass mark is above 40
sno | name | result |
---|---|---|
1 | Sachin | Fail |
2 | Sachin | Pass |
3 | Kohli | Fail |
4 | Ganguly | Pass |
Query:
SELECT sno, name, CASE WHEN mark >= 40 THEN 'Pass' ELSE 'Fail' END AS Result FROM student
Wednesday, March 28, 2012
Pass the form values from one domain to another domain with POST values.
yes. we can pass the form values from one domain to another domain with using POST method. We have to add action attribute in <form> tag.
<form method="POST" action="http://www.anotherdomain.com" target="_parent">
</form>
Tuesday, March 27, 2012
Restrict cut, copy and paste in text area using Jquery
HTML:
<textarea id="textarea_id" > </textarea>
Script:
$(document).ready(function() {
$('#textarea_id').bind('cut copy paste', function(e) { e.preventDefault(); });
});
Remove or Delete duplicate records in a table in MySQL
Remove the duplicate records in a table, it will delete records which is having greater than the sno
For example: table name: players
sno | name | coach_id |
---|---|---|
1 | Sachin | 1 |
2 | Sachin | 5 |
3 | Kohli | 1 |
4 | Ganguly | 2 |
5 | Kohli | 4 |
6 | Gambir | 3 |
Query:
DELETE FROM players USING players , players AS virtualtable
WHERE players .sno > virtualtable.sno
AND players .name = virtualtable.name
Output:
sno | name | coach_id |
---|---|---|
1 | Sachin | 1 |
3 | Kohli | 1 |
4 | Ganguly | 2 |
6 | Gambir | 3 |
Display limited records with out using LIMIT in MySQL
If you want to get display limited records with out using LIMIT option in MySQL.
For example: table name: players
sno | name | coach_id |
---|---|---|
1 | Sachin | 1 |
2 | Dravid | 5 |
3 | Kohli | 1 |
4 | Ganguly | 2 |
5 | Sehwag | 4 |
6 | Gambir | 3 |
Query:
SELECT one.sno, one.name FROM players AS one
WHERE ( SELECT COUNT(*) FROM players AS two WHERE two.sno <= one.sno ) <= 3
Output:
sno | name | coach_id |
---|---|---|
1 | Sachin | 1 |
2 | Dravid | 5 |
3 | Kohli | 1 |
Get data condition related information from a single table
If you want to display the data with condition based from a single table.
Query:
For example: table name: players
sno | name | coach_id |
---|---|---|
1 | Sachin | 1 |
2 | Dravid | 5 |
3 | Kohli | 1 |
4 | Ganguly | 2 |
5 | Sehwag | 4 |
6 | Gambir | 3 |
Query:
SELECT player.sno, player.name, coach.name AS coachname
FROM players AS coach
JOIN players AS player ON coach.sno = player.coach_id
Output:
sno | name | coach_id |
---|---|---|
1 | Sachin | Sachin |
2 | Dravid | Sehwag |
3 | Kohli | Sachin |
4 | Ganguly | Dravid |
5 | Sehwag | Ganguly |
6 | Gambir | Kohli |
Thursday, March 8, 2012
Facebook and Drupal 6 Implementation
Drupal for Facebook
1.Download Drupal for Facebook Module. And place into sites/all/modules folder.
2.Download Facebook-PHP-SDK library and place into sites/all/libraries folder. Folder should be facebook-php-sdk.
3.In settings.php files, you have to add the following lines,
1.include "sites/all/modules/fb/fb_url_rewrite.inc";
2.include "sites/all/modules/fb/fb_settings.inc";
3.$conf['fb_api_file'] = 'sites/all/libraries/facebook-php-sdk/src/facebook.php';
4.Then enable the following module
1.fb.module
2.fb_app.module
3.fb_connect.module
4.fb_user.module
5.Goto admin/reports/status page and verify the Facebook PHP SDK loaded or not.
6.Then you have to generate the API/Secret key in facebook for your site.
1.App Display Name - Your application display name – Human readable without space
2.App Namespace: Your namespace of your domain (All letters are small)
3.Contact Email – Your Email id
4.Category – Other
5.Website – Site URL – http://www.domain/com
7.Go to admin/build/fb page and configure the Application for Facebook API settings.
8.You have add the following attribute in your html tag: xmlns:fb="http://www.facebook.com/2008/fbml"
Login Button Interface
=================
Manual
---------
Required Versions:
==============
Drupal 6.x
DFF - 6.x-3.0-beta1
facebook-php-sdk - Facebook PHP SDK (v.3.1.1)
Issues in DFF and Drupal
===================
Whereever they using getSession() function inside fb module folder, we have to repalce getUser() function. Because getSession() is not exist in Facebook PHP SDK kit.
1.Download Drupal for Facebook Module. And place into sites/all/modules folder.
2.Download Facebook-PHP-SDK library and place into sites/all/libraries folder. Folder should be facebook-php-sdk.
3.In settings.php files, you have to add the following lines,
1.include "sites/all/modules/fb/fb_url_rewrite.inc";
2.include "sites/all/modules/fb/fb_settings.inc";
3.$conf['fb_api_file'] = 'sites/all/libraries/facebook-php-sdk/src/facebook.php';
4.Then enable the following module
1.fb.module
2.fb_app.module
3.fb_connect.module
4.fb_user.module
5.Goto admin/reports/status page and verify the Facebook PHP SDK loaded or not.
6.Then you have to generate the API/Secret key in facebook for your site.
1.App Display Name - Your application display name – Human readable without space
2.App Namespace: Your namespace of your domain (All letters are small)
3.Contact Email – Your Email id
4.Category – Other
5.Website – Site URL – http://www.domain/com
7.Go to admin/build/fb page and configure the Application for Facebook API settings.
8.You have add the following attribute in your html tag: xmlns:fb="http://www.facebook.com/2008/fbml"
Login Button Interface
=================
Manual
---------
$_fb_app = fb_invoke(FB_OP_CURRENT_APP);
$facebook = new Facebook(array(
'appId' => $_fb_app->apikey,
'secret' => $_fb_app->secret,
'cookie' => true,
));
$loginUrl = $facebook->getLoginUrl();
global $base_url;
$params = array( 'next' => $base_url . '/' ); // Custom redirection after logout link press
$logoutUrl = $facebook->getLogoutUrl($params);
?>
Or Drupal Theme
print theme('fb_login_button', t('Connect with Facebook'), array('attributes' => array('size' => 'large', 'background' => 'dark', 'onclick' => 'removePopup();')));
Or FML Tag
<fb:login-button>Connect with Facebook < /fb:login-button>
Or Javascript
<a href=”javascript: doLogin();” > Connect with Facebook < /a>
JS:
doLogin();
function doLogin() {
FB.login(function(response) {
if (response.session) {
FB.api('/me', function(response) {
//alert('User: ' + response.name);
//alert('Full details: ' + JSON.stringify(response));
}
);
}
} , {perms:''});
}
Required Versions:
==============
Drupal 6.x
DFF - 6.x-3.0-beta1
facebook-php-sdk - Facebook PHP SDK (v.3.1.1)
Issues in DFF and Drupal
===================
Whereever they using getSession() function inside fb module folder, we have to repalce getUser() function. Because getSession() is not exist in Facebook PHP SDK kit.
Subscribe to:
Posts (Atom)