Thursday, December 6, 2012

Convert First letter a string to capital

Here is the function which is used to convert all the first letters of the name to capital Letters. 

 This idea of creating this  function is inspired with the words of my colleague   Kamal Relwani

Sunday, November 4, 2012

How to create a facebook add friend request

Using JavaScript :
 Things Required all u need to do i call
  1. Call FB.init Method -
    FB.init({  appId  : 'YOUR_APP_ID',  frictionlessRequests : true });
  2. To send request for purticular friends
    1. function sendRequestToRecipients(){ FB.ui ({method: 'apprequests', message: 'My Request', to: '12345,23456' }, requestCallback); }
  1.  To send request for all friends
    1. function sendRequestViaMultiFriendSelector() {
        FB.ui({method: 'apprequests',
          message: 'My  Request'
        }, callbackfunction());
      }
       callbackfunction(response){
       alert(response);
      }
  

Wednesday, October 3, 2012

Create a Date Drop down

Creating a Date year and Date drop down which is validated based on leap year and date 

Here is the code please add jquery script tag before you include the code


 function fnDate(){
try{
for(var i=1950;i<=2009;i++){
jq("#dobyy").append("<option value="+i+">"+i+"</option>");
}
for(var i=1;i<=12;i++){
jq("#dobmm").append("<option value="+i+">"+i+"</option>");
}

var month = '';
var year = '';
jq("#dobmm").change(function(){
month = jq("#dobmm").val();
year = jq("#dobyy").val();
var aOddMnth = ["1","3","5","7","8","10","12"];
var aEvnMnth = ["4","6","9","11"];
jq("#dobdd").html("<select name=\"dobdd\" id=\"dobdd\" title=\"1\" style=\"width:84px;\"><option value=\"\">Day</option></select>&nbsp;&nbsp;&nbsp;&nbsp;");
if(month > 0){
if(month == "2"){
if(year%4 == 0){
for(var i=1;i<=29;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}else{
for(var i=1;i<=28;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
}
if(jq.inArray(month,aOddMnth) != -1){
for(var i=1;i<=31;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
if(jq.inArray(month,aEvnMnth) != -1){
for(var i=1;i<=30;i++){
jq("#dobdd").append("<option value="+i+">"+i+"</option>");
}
}
}
});
}catch(e){
alert(e.message)
}
}

Sunday, April 1, 2012

A simple Shopping Cart code in PHP

Here is a simple way to code to code the shopping cart i have seen in many websites for the code but i hope i have done using basic simple concepts of PHP to code the Shopping cart

Here is the link to download the source code - download

Instructions for using that code
  1. Extract the ca.rar
  2. place ca folder in www folder
  3. Execute the backup file or use scripts present in dbscripts folder to create new tables
  4. Now run localhost/ca to execute the code 

 

Tuesday, March 27, 2012

Get Url From Browser in Php

Getting the URL  from the parent window when you use a popup. This small Example code might help you to get the url from the parent window this can be used normal windows also

 if(isset($_SERVER['HTTP_REFERER']))
{
   
    $strPrevScheme = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_SCHEME);
 
    $strPrevHost = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
 
    $strPrevPath = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH);
 
    $strPrevURL = urlencode($strPrevScheme.'://'.$strPrevHost.$strPrevPath);
   
   
}

the parse_url(url) gives the following array 

Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)
 

 
reference - http://in2.php.net/manual/en/function.parse-url.php 

Monday, March 26, 2012

Finding the Count of all Charecters entered


<?php
/******************************************************************************
 * Filename: totalnumberofalphabets.php
 * Description: The file is used to count the number of occurences of each charecter
 * Author: G Jayendra Kartheek
 * Date Created: 26 Mar 2012
 * Copyright © 2012 All rights reserved
 ******************************************************************************/

//after user submits the values
if (isset($_POST['butSubmit']) && '' != $_POST['butSubmit']) {

    //taking the charecter into the array
    $strValue = str_split($_POST['txtInput']);
    //copying the string array
    $strDuplicate = $strValue;
   
    $iIntI = 0;
    //based on the string length travesing the array
    while ($iIntI < strlen($_POST['txtInput'])) {
        //initializing the count and j for every iteration
        $iCount = 0;
        $iIntIIntJ = 0;
        //comparing each and every element  and finding the count of each element
        while ($iIntIIntJ < strlen($_POST['txtInput'])) {
            if ($strDuplicate[$iIntI] == $strValue[$iIntIIntJ]) {

                $iCount++;
            }
            $iIntIIntJ++;
        }
        //printing the count
        echo '<br>Number of times "' . $strDuplicate[$iIntI] . '" repeated is : ' . $iCount;
        $iIntI++;
    }
}
?>
<form name="" method ="POST">
    <input type='text' name = 'txtInput'/><input type = 'submit' name= 'butSubmit' value ="OK"/>
</FORM>

Thursday, March 22, 2012

Closing the PopUp and redirecting Parent Window

I have tried for few hours to solve this problem Here is the simple example which helps you to solve the Problem

Problem:
 Create a PopUp window on submission of a value in PopUp the PopUp Closes and the Parent Windows redirects to Some other Page 

Solution:
Here is the simple way to solve it

Create 2 php pages

1. popup.php
Copy this Code

<html>
    <head>    
    </head>
    <body>
        <a href="#" onclick="window.open('popupcode.php','Login','height=500,width=420,scrollbars=yes');return false;">PopUp</a>
    </body>
    </html>