• Hi, whats up?

    I’m writing my first plugin, and i’ve already enqueue my js file, but i’m not able to listen to the change events on my form.

    I have this selectbox:

    add_settings_field(
    		'wcwp_select_wcwp_select_state',
    		__( 'Select the state', 'woocommerce-withdrawal-point-for-brazil' ),
    		'wcwp_select_state_render',
    		'wcpc_pluginPage',
    		'wcwp_pluginPage_section'
    	);
    
    <!-- HERE ITS THE SELECT -->
    <select name='wcwp_settings_wcwp_select_state' id="wcwp_select_wcwp_select_state">
    		<option value='1'>Acre</option>
    		<option value='2'>Alagoas</option>
    		<option value='3'>Amapá</option>
    		<option value='4'>Amazonas</option>
    </select>

    And this is my js script:

    var selectBox = document.getElementById("wcwp_select_wcwp_select_state");
    selectBox.addEventListener("change", function(){
        alert("Works!");
    });

    But its not listening to my change event, do you know why??

    Thanks a lot ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Does the console show any errors?

    Does this work with plugins deactivated?

    Is the JS file being loaded?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    It would be significantly easier to help if you’d provide a link to the Webpage in question.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Writing JavaScript for my plugin’ is closed to new replies.