Showing posts with label WebDevelopment. Show all posts
Showing posts with label WebDevelopment. Show all posts

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)
}
}

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 

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>