• Resolved ele

    (@luishgc93)


    hello, i try add onChange on select, but i cant.
    I try use this:

    
    function addAttributeToDropdown($html_content){
      $html_content = str_replace('<select','<select onChange="ponPaises(this.form)"',$html_content);
      return $html_content; 
    }
    
    add_filter('wp_dropdown_cats','addAttributeToDropdown');

    but dont work, thanks for help me,

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    hello, i try add onChange on select, but i cant.

    Thanks for providing your code.
    What is it you are trying to do?

    Kind regards,

    Thread Starter ele

    (@luishgc93)

    @conschneider hello, and thanks for help me.
    I try insert onChange=”ponPaises(this.form)”
    on select.

    If my code es:

    
    <span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-region-container"><span class="select2-selection__rendered" id="select2-region-container" title="Europa"><span class="select2-selection__clear">×</span>Europa</span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span>

    and i need add onChange=”ponPaises(this.form)” on this span. Because i use a javascript.

    • This reply was modified 4 years, 4 months ago by ele.
    Plugin Support con

    (@conschneider)

    Engineer

    Hi again,

    Ah I see. You are trying to change the markup with that PHP function addAttributeToDropdown so it contains your event listener.

    * wp_dropdown_cats is deprecated.
    * Instead wp_dropdown_categories is encouraged.
    * But neither of those two are hooks. They are functions. Therefore: add_filter('wp_dropdown_cats','addAttributeToDropdown'); cannot work.

    You need a filter that is attached to the HTML output selection.
    Tell me which selection form you are trying to edit. Where can I see this?

    Kind regards,

    Thread Starter ele

    (@luishgc93)

    @conschneider thanks ! its works , but on my web dont work great with this javascript,

    https://eos.webcaceres.com/

    on checkout, region and pais are bugged.

    • This reply was modified 4 years, 4 months ago by ele.
    Plugin Support con

    (@conschneider)

    Engineer

    Hi again,

    thanks ! its works,

    All right then.
    ..

    but on my web dont work great with this javascript,
    https://eos.webcaceres.com/
    on checkout, region and pais are bugged.

    How do you trigger the error?
    What does the error message say?

    Thread Starter ele

    (@luishgc93)

    @conschneider resolved!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘add onChange on select’ is closed to new replies.