switch function on load | WordPress.org

[ad_1]

Good afternoon. I would like to know if you can help me with a question? I have a switch function, whose initial value, when the page is loaded, is assigned by another switch function. It happens that when loading the page, the first function mentioned does not run completely.

The value contained in fieldname1 is correct, as it gives the desired values. fieldname2 is a radioButtons field. Both functions below are in a Calculated Field. Is it possible for them to help?

Here’s the example:

var url = fieldname1;

switch(url) {
    case 1:
        getField(2).setVal('1');

        break;
    case 2:
        getField(2).setVal('2');

        break;
    case 3:
        getField(2).setVal('3');

        break;

    default:
        return ('1');

        break;
}

})();

(function masterSwitch(){
var css = {};

switch(fieldname2) {
    case 1:
        css['border'] = ' solid transparent';
        css['borderImage'] = 'url(image1.png) 30';           
        break;
    case 2:
        css['border'] = ' solid transparent';
        css['borderImage'] = 'url(image2.png) 30';
        break;
    case 3:
        css['border'] = ' solid transparent';
        css['borderImage'] = 'url(image3.png) 30';
        break;

    default:
        css['border'] = ' solid transparent';
        css['borderImage'] = 'url(image1.png) 30';
        break;
}

jQuery('#image').each(function(){jQuery(this).css(css);});

})();

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer