Friday, September 19, 2014

paypal in php





<script>
function validate(){
var obj=document.frmPayPal;
//alert("Design");
//var obj=valobj.frmPayPal;

if(obj.amount.value==""){
alert("Please Enter Amount!");
obj.amount.focus();
return false;
}else if(isNaN(obj.amount.value)){
alert("Enter Number Only!");
obj.amount.focus();
return false();
}else if(obj.currency_code.value==""){
alert("Please Select Currency!");
obj.currency_code.focus();
return false;
}else{
return true;
}
}
</script>





<!-- <form id="frmPayPal" name="frmPayPal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" onsubmit="return validate(this)"> -->


                <form id="frmPayPal" name="frmPayPal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="return validate(this)" >

<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="sumanprabhha80@gmail.com">
<input type="hidden" name="item_name" value="Pay for Us">
<input type="hidden" name="item_number" value="1">
  <!-- <input type="hidden" name="amount" value="500"> -->
Amount : <input type="text" name="amount" value="">
</br>
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">

  <!-- <input type="hidden" name="currency_code" value="EUR">  -->
Currency : <select name="currency_code">
<option value="USD">U.S. Dollars</option>
<option value="EUR">Euros</option>
<option value="AUD">Australian Dollars</option>
</select>
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="">
<input type="hidden" name="notify_url" value="">
<!-- <input type="hidden" name="cancel_return" value="<?php //$cencelRetUrl?>"> -->
</br>
<button type="submit">Submit</button>
 <!--  <input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1">-->
</form>
               

Saturday, August 30, 2014

Getting the first image in string with php


<?php
    $texthtml = 'Who is Sara Bareilles on Sing Off<br>
    <img alt="Sara" title="Sara" src="475993565.jpg"/><br>
    <img alt="Sara" title="Sara two" src="475993434343434.jpg"/><br>';
    preg_match('/<img.+src=[\'"](?P<src>.+)[\'"].*>/i', $texthtml, $image);
    echo $image['src'];
?>

Thursday, April 24, 2014

get child element value in javascript


example:

<p id="note_dimension" class="note"><span>TEst3</span></p>

var trextValue=document.getElementById(note_dimension).childNodes[0].innerHTML;
alert(trextValue);

Friday, April 4, 2014

javascript to get previous page url

        1. history.go(-1);
2. var ex=document.referrer;
3. window.history.back();

Monday, March 31, 2014

select and unselect all checkbox by javascript




<div class="mt10">

<a href="javascript:;" class="c068 bline" onclick="getCheckedBoxes('check[]',1)">Select all</a>&nbsp;&nbsp;&nbsp;&nbsp;

<a href="javascript:;" class="c068 bline" onclick="getCheckedBoxes('check[]',2)">Select none</a>&nbsp;&nbsp;&nbsp;&nbsp;

<a href="javascript:;" class="c068 bline" onclick="return deletfavorite();">Delete selected</a>

<!-- <form name="searchForm" action="" method="post">
<input id="key" name="search" style="width:200px" value="" class="input1" type="text">
<input type="submit" name="submit" value="Search">
</form> -->
</div>
<form name="list" method="post" action="">
<p>
<input name="check[]" type="checkbox" value="11">c1
</p>
<p>
<input name="check[]" type="checkbox" value="11">c2
</p>
<p>
<input name="check[]" type="checkbox" value="11">c3
</p>
<p>
<input name="check[]" type="checkbox" value="11">c4
</p>
</form>


<script>

 jQuery('#mydesign').attr('class','active');

function getCheckedBoxes(chkboxName,val) {

 var checkboxes = document.getElementsByName(chkboxName);

 var checkboxesChecked = [];

 // loop over them all

   for (var i=0; i<checkboxes.length; i++) {

// And stick the checked ones onto an array...

if(val==1){

checkboxes[i].checked='checked';

}

 if(val==2){

  checkboxes[i].checked='';

 }



 }



}





function deletfavorite(){

var checkboxes = document.getElementsByName('check[]');

$check=false;

for (var i=0; i<checkboxes.length; i++) {

if(checkboxes[i].checked){

$check=true;

break;

}



}



if($check){

var r=confirm("Conform to Delete!")

if (r==true){

document.list.submit();

}else{

return false;

}



}else{

alert('Check At list One Option!');

}



}





</script>

Wednesday, March 12, 2014

Creating Thumbnails with PHP using the GD Library

<?php
function getBaseResizeImage($sourceImgPath,$destinatioImgPath,$resizePercentage,$extensiontoConvert=''){
/*
* PHP GD
* resize an image using GD library
*/

// File and new size
//the original image
$filename=file_get_contents($sourceImgPath);
$filename2 = $sourceImgPath;


if($extensiontoConvert==''):
$ext = pathinfo($filename2, PATHINFO_EXTENSION);
else:
$ext=$extensiontoConvert;
endif;

//the resize will be a percent of the original size
$percent = $resizePercentage;

// Content type
header('Content-Type: image/jpeg');
header('Content-Type: image/png');
 

// Get new sizes
list($width, $height) = getimagesize($filename2);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth,$newheight);
$source = imagecreatefromstring($filename);

// Resize
imagecopyresized($thumb,$source,0,0,0,0,$newwidth,$newheight,$width,$height);

// Output and free memory
//the resized image will
if($ext=='jpg'):
$destPath=$destinatioImgPath;
imagejpeg($thumb,$destPath);
endif;
if($ext=='png'):
$destPath=$destinatioImgPath;
imagepng($thumb,$destPath);
endif;
//imagedestroy($thumb);
}
$sourceImgPath='2879.jpg';
$destinatioImgPath='ram.png';
$resizePercentage='0.5';
$extensiontoConvert='png';
getBaseResizeImage($sourceImgPath,$destinatioImgPath,$resizePercentage,$extensiontoConvert);
?>

resize image and change type by GD livery in php

<?php

function getBaseResizeImage($sourceImgPath,$destinatioImgPath,$resizePercentage,$extensiontoConvert=''){
/*
* PHP GD
* resize an image using GD library
*/

// File and new size
//the original image
$filename=file_get_contents($sourceImgPath);
$filename2 = $sourceImgPath;


if($extensiontoConvert==''):
$ext = pathinfo($filename2, PATHINFO_EXTENSION);
else:
$ext=$extensiontoConvert;
endif;

//the resize will be a percent of the original size
$percent = $resizePercentage;

// Content type
header('Content-Type: image/jpeg');
header('Content-Type: image/png');
 

// Get new sizes
list($width, $height) = getimagesize($filename2);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth,$newheight);
$source = imagecreatefromstring($filename);

// Resize
imagecopyresized($thumb,$source,0,0,0,0,$newwidth,$newheight,$width,$height);

// Output and free memory
//the resized image will
if($ext=='jpg'):
$destPath=$destinatioImgPath;
imagejpeg($thumb,$destPath);
endif;
if($ext=='png'):
$destPath=$destinatioImgPath;
imagepng($thumb,$destPath);
endif;
//imagedestroy($thumb);
}
$sourceImgPath='2879.jpg';
$destinatioImgPath='ram.png';
$resizePercentage='0.5';
$extensiontoConvert='png';
getBaseResizeImage($sourceImgPath,$destinatioImgPath,$resizePercentage,$extensiontoConvert);
?>

Tuesday, March 11, 2014

add remove text box by javascript

<div id="content" class="add-images">
                    <div><ul><li>Label</li><li>Width</li><li>X</li><li>Height</li></div>
                    <div class="add-fil">
                   
                    <input name="label[]" type="text">
                    <input name="width[]" type="text">X
                    <input name="height[]" type="text">
                   
                    </div>
                    <div style="float:left;">
                        <input name=""  class="btn-all" type="button" value=" + " onclick="addInputFile()">
                        <input name="" class="btn-all" type="button" value=" - " onclick="removeElement()">
                        <input id="uploadButton" style="margin-top:8px;" class="" name="uploadButton"  type="submit" value="Submit My Work">
                    </div>
                </div>
               
                <script type="text/javascript">
            var intTextBox=0;
            //FUNCTION TO ADD TEXT BOX ELEMENT
            function addInputFile()
            {
                intTextBox = intTextBox + 1;
                var contentID = document.getElementById('content');
                var newTBDiv = document.createElement('div');
                newTBDiv.setAttribute('id','strText'+intTextBox);
                newTBDiv.setAttribute('class','strText');
                newTBDiv.innerHTML = "<input name='label[]' type='text'><input name='width[]' type='test'>X<input name='height[]' type='text' id='" + intTextBox + "' >";
                contentID.appendChild(newTBDiv);
            }
            //FUNCTION TO REMOVE TEXT BOX ELEMENT
            function removeElement()
            {
                if(intTextBox != 0)
                {
                    var contentID = document.getElementById('content');
                    contentID.removeChild(document.getElementById('strText'+intTextBox));
                    intTextBox = intTextBox-1;
                }
            }
        </script>

Sunday, January 26, 2014

image share facebook button

<a title="send to Facebook"
 href="http://www.facebook.com/sharer.php?s=100&p[title]=Omegabanner&p[summary]=Omegabanner Design&p[url]=YOUR_URL&p[images[0]=http://67.222.139.226/clients/omegabanners/images/designs/1390804366_0.png"
 target="_blank">
 <span>
<img width="14" height="14" src="'icons/fb.gif" alt="Facebook" /> Facebook
 </span>
</a>

Saturday, January 25, 2014

get multi selected options value


<select multiple onchange="assignCategory(this.id)" style="width:120px;" id="category_0" name="category">
<option value="0">select category</option>
<option value="5">Banners</option>

<option value="16">Out door banner stands</option>
<option value="6">Window signs</option>
<option value="26">&nbsp; &nbsp;Window sign (perforated)</option>
<option value="27">Window sign (opaque)</option>
<option value="28">Window cling. (opaque)</option>
<option value="7">Side walk signs</option>
<option value="11">Banner accessories</option>
<option value="29">Faqs</option>
</select>



<script>

function assignCategory(objThisId){
var InvForm=document.getElementById(objThisId).options.length;
var optL=document.getElementById(objThisId).options;
var x=0;
var selBranchVal='';
for (x=0;x<=InvForm;x++)
         {
//alert("op:"+optL[x].value+'opsel:'+optL[x].selected);
// alert($(optL[x]).selected);
           if(optL[x]){
if($(optL[x]).selected)
{
//alert('jha'+optL[x].value);
//alert(InvForm.SelBranch[x].value);
selBranchVal= selBranchVal+optL[x].value+",";
// alert("sds"+selBranchVal);

}
         }
alert(selBranchVal);
}
</script>

Friday, January 10, 2014

array object in php

$makedata=(Object)$makedata;
$makedata->product=$product_id;
$makedata->super_attribute=$super_attribute;
$makedata->sizeN=$_REQUEST['sizeN'];