• I am looking to find out if I can place a script in a button so activation of it will triggers the script.
    If it is possible, which and where do I place the various elements in the button?
    I hope someone can help me!

    The code for my button looks like this:
    For Test
    And the script I wish to trigger looks like this:
    <script>
    jQuery(document).ready(function($) {
    $(‘.selected-package_3400’).click(function(){
    var title = $(“.pack_title_3400”).attr(‘packtitle’);
    var packid = “3400”;
    var current_user_email = “XXX@XXXXXXXXXXXX.co.uk”;
    var current_user_id = “11”;
    var price = $(“.price_3400”).attr(‘packprice’);
    var price1 = $(“.price_3400”).attr(‘packprice1’);
    var time = $(“.pack_time_3400”).attr(‘packtime’);
    var recurring = $(“.pack_recurring_3400”).attr(‘recurring’);
    var listing = $(“.pack_listing_3400”).attr(‘listing’);
    var featured_listing = $(“.pack_featured_listing_3400”).attr(‘featured_listing’);
    var pack_date = $(“.pack_time_3400”).attr(‘pack_date’);
    var pack_time = $(“.pack_time_3400”).attr(‘pack_time’);
    var paypalMerchantEmail1 = “”;
    var paypalUrlmode = “sandbox”;
    var pack_currency = “£”;
    var currency_placement = “before”;
    var currency_code11 = “USD”;
    var currency_sign1 = “£”;
    if(price1 == 0){
    var data = {
    action: ‘packages_free_action’,
    current_user_email: current_user_email,
    current_user_id: current_user_id,
    title: title,
    time: time,
    packid: packid,
    price: price,
    price1: price1,
    listing: listing,
    recurring: recurring,
    featured_listing: featured_listing,
    pack_date: pack_date,
    pack_time: pack_time,
    paypalMerchantEmail1: paypalMerchantEmail1,
    paypalUrlmode: paypalUrlmode,
    pack_currency: pack_currency,
    currency_placement: currency_placement
    };
    $(‘#loadingmessage’).show();
    $.ajax({
    type: ‘POST’,
    url: “https://XXXXXXXX.com/wp-admin/admin-ajax.php&#8221;,
    data: data,
    success: function(response) {
    if(response !=””){
    $(“.response”).html(”).html(response);
    $(“.tablinks”).removeClass(‘active’);
    $(“.tablinks:nth-child(3)”).addClass(‘active’)
    $(“.tabcontent”).css(‘display’,’none’);
    $(“#Done”).css(‘display’,’block’);
    $(‘#loadingmessage’).hide();
    }
    else{
    console.log(’empty’);
    }
    }
    })
    }
    else{
    var data = {
    action: ‘packages_pass_action’,
    current_user_email: current_user_email,
    current_user_id: current_user_id,
    title: title,
    time: time,
    packid: packid,
    price: price,
    price1: price1,
    listing: listing,
    recurring: recurring,
    featured_listing: featured_listing,
    pack_date: pack_date,
    pack_time: pack_time,
    paypalMerchantEmail1: paypalMerchantEmail1,
    paypalUrlmode: paypalUrlmode,
    pack_currency: pack_currency,
    currency_placement: currency_placement,
    currency_code11: currency_code11,
    currency_sign1: currency_sign1

    };
    $(‘#loadingmessage’).show();
    $.ajax({
    type: ‘POST’,
    url: “https://XXXXXXXXXXXX.com/wp-admin/admin-ajax.php&#8221;,
    data: data,
    success: function(response) {
    if(response !=””){
    $(“.payment-content”).html(”).html(response);
    $(“.tablinks”).removeClass(‘active’);
    $(“.tablinks:nth-child(2)”).addClass(‘active’)
    $(“.tabcontent”).css(‘display’,’none’);
    $(“#Payment”).css(‘display’,’block’);
    $(‘#loadingmessage’).hide();
    }
    else{
    console.log(’empty’);
    }
    }
    })
    }
    });
    });
    </Script>

  • The topic ‘Script in buttons?’ is closed to new replies.