Banner Ad

    A    L    W    A    Y    S           D    E    S    I    R    E           T    O           L    E    A    R    N           S    O    M    E    T    H    I    N    G           U    S    E    F    U    L   

Technology and business

technology and business are becoming inextricably interwoven. I don't think anybody can talk meaningfully about one without the talking about the other

Arthur C. Clarke

Any sufficiently advanced technology is indistinguishable from magic.

Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.

Softwares

Defect-free software does not exist.

Technology is like a fish. The longer it stays on the shelf, the less desirable it becomes.

Sunday, September 1, 2013

Easy and fast way to add PayPal payment gateway to your website

following is paypal Buy now button java script code
You need to add paypal-button.min.js   click here to download and
add as follows between your <head> tag 



or add github URL https://raw.github.com/paypal/JavaScriptButtons/master/dist/paypal-button.min.js


<script 
    data-callback="http://sep06.netne.net/online_portal/controller_b/post_ad/success" 
    data-tax="0" 
    data-shipping="0" 
    data-amount="5.5" 
    data-name="harsha" 
    data-button="buynow" src="https://raw.github.com/paypal/JavaScriptButtons/master/dist/paypal-button.min.js?merchant=harshagayan90@gmail.com"
>
</script>





here you need to customize your code as followsmerchant="Your paypal email"
data-name="What you need to appear in pay slip"
data-amount="How much money you want in $ s"

PHP codigniter ajax call to load dropdown when another dropdown changes

<select id="makes2" name="makes2" style="width:200px;" data-hint="" onchange="load_dropdown_content1($('#field2'), this.value)">
                          <?php 
$sql = mysql_query("SELECT distinct make FROM advertisements");
while ($row = mysql_fetch_array($sql)){
echo "<option value='".$row['make']."'>" . $row['make'] . "</option>";
}
?>

</select>



here my values are hard coded to load values from mysql database

when dropdown onchange() function following javascript function will be called


here my controller compareVehicles --> get_dropdown_values1 function is called asynchronously



<script type="text/javascript">


function load_dropdown_content1(field_dropdown1, selected_value1){
   var result = $.ajax({
        'url' : '<?php echo site_url('compareVehicles/get_dropdown_values1'); ?>/'+selected_value1,
        'async' : false
    }).responseText;
    field_dropdown1.replaceWith(result);





}


inside the controller my function as follows



function get_dropdown_values1($filter11){

        $this->load->model('model_c/cmp_vehi_model');

        $result1 = $this->cmp_vehi_model->get_options1($filter11);

foreach($result1 as  $key1 => $value1){

$final1 = array('{$key1}' => $value1);

}

        $this->load->helper('form');

       
echo "<select name=\"field2\" id=\"field2\" onchange=\"load_dropdown_contentad($('#field5'), this.value);\" onblur=\"load_dropdown_contentad($('#field5'), this.value);\"  onfocus=\"load_dropdown_contentad($('#field5'), this.value);\"  style=\"width:200px\"  >";
    

foreach($result1 as  $key1 => $value1){
echo"<option value='{$value1}'>{$value1}</option>";
}

echo "</select>";


    }





model that is calling from controller as follows


function get_options1($filter11){

$query1 = $this->db->query("SELECT distinct modelnumber FROM advertisements WHERE make LIKE '".$filter11."'");
$result1 = $query1->result_array();

$x1 = array();
foreach($result1 as $i1){

array_push($x1, $i1['modelnumber']);

}


 
        return $x1;

    }



in my controller php code is  echo to load ajax called dropdown
Please go to following link to see how it works
http://sep06.netne.net/online_portal/index.php/controller_c/compareVehicles/cmpVehicles

How to define static javascript variable

<script type="text/javascript">
checkadid.count=0;
checkadid.adid="";



function checkadid(checkbox)
{

checkadid.adid=checkadid.adid.concat(checkbox.value);

    if (checkbox.checked)
    {
        
    }


}

</script>


here my javascript static variable is checkadid.adid
since javascripts are weakly type there is no hard and fast rules you need to define variable as above

and i used this static variable access to following java script function


function load_table(){


 
var aid=checkadid.adid;
 
if(aid.length<=6){
 
alert("Please select at least 2 advertistment")
 
}
else{
     window.location.href="<?php echo site_url('controller_c/compareVehicles/ctable'); ?>?aid="+aid;

}

  }



static java script variable can access from any where within any javascript function

Click here to learn about javascript variables





Related Posts Plugin for WordPress, Blogger...

your comments