0

I have two issues in this code:

1: if I keep clicking on the radio button the message will be repeated. 
2: I cannot translate the message to other language.

Here is my jquery code:

<script type="text/javascript">
jQuery(document).ready(function($){
    $('#co-payment-form dt input').on('click', function(){
        if($(this).val() == 'paytabs_server'){
            $(this).next().append('<span id="paytab_message">Please make sure to enable Cookies from your browser!</span>')
        }else{
            $('#paytab_message').remove();
        }
    });
});

3
  • Use .one(): $('#co-payment-form dt input').one('click', function(){ }); To execute only once click funcation
    – shail
    Jul 23, 2018 at 12:06
  • Did you write this script on any phtml file? Jul 23, 2018 at 12:30
  • @SukumarGorai I have added this script in my footer Jul 23, 2018 at 12:37

1 Answer 1

1

Use the below code, it should work if you are using the script in your footer.phtml file:

<script type="text/javascript">
    jQuery(document).ready(function($){
        var text = "<?php echo $this->__('Please make sure to enable Cookies from your browser!') ?>";
        $('#co-payment-form dt input').on('click', function(){
            if($(this).val() == 'paytabs_server'){
                if($('#paytab_message').length == 0)
                    $(this).next().append('<span id="paytab_message">'+text+'</span>')
            }else{
                $('#paytab_message').remove();
            }
        });
    });
</script>
2
  • Worked like a charm! ..thank you alot @Sukumar Gorai Jul 23, 2018 at 12:49
  • Welcome. Happy to Help! Jul 23, 2018 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.