Change checkbox into select list in wordpress

Change checkbox into select list in wordpress

Hi. I have to change a checkbox group items of a form into a list (select option).
I have tried locally using a simple html page in which copy the form code with classes and attributes.
and with that following code everythings works fine, but when i insert the code into the head section of my wordpress nothing happens.


the jquery code:
  1. $(document).ready(function(){
                var selname = $('.mailpoet_paragraph').find('input:checkbox').attr('name');  /*seleziona il primo p con input checkbox e legge il nome */
                var addselect = $("<select name='" + selname + "'></select>");     /* crea il select html tag */
                $('form > p:eq(1)').after(addselect);  /* aggiunge il select dopo il primo p del form (ossia prima della email) */
               
                $('.mailpoet_checkbox_label').each(function(){
                $('select').append('<option value="'+$(this).find(' > input').val() +'">'+$(this).text()+' </option>'); 
                /* per ogni label con classe checkbox, aggiungi al select creato prima (unico nella pagina) e imposta opzioni con i valori dei checkbox */
                });
               
                $('form > p:eq(1)').find('label').hide();
                $('form > p:eq(1)').find('label:first').show();
                           
            });
 the form html code
  1. <div id="mailpoet_form_1" class="mailpoet_form mailpoet_form_shortcode">
        <style type="text/css">#mailpoet_form_1 .mailpoet_form {
    }
    #mailpoet_form_1 .mailpoet_paragraph {
    }
    #mailpoet_form_1 .mailpoet_text_label,
    #mailpoet_form_1 .mailpoet_textarea_label,
    #mailpoet_form_1 .mailpoet_select_label,
    #mailpoet_form_1 .mailpoet_radio_label,
    #mailpoet_form_1 .mailpoet_checkbox_label,
    #mailpoet_form_1 .mailpoet_list_label,
    #mailpoet_form_1 .mailpoet_date_label {
    	display: block;
    }
    #mailpoet_form_1 .mailpoet_text,
    #mailpoet_form_1 .mailpoet_textarea,
    #mailpoet_form_1 .mailpoet_select,
    #mailpoet_form_1 .mailpoet_date {
    	display: block;
    }
    #mailpoet_form_1 .mailpoet_checkbox {
    }
    #mailpoet_form_1 .mailpoet_validate_success {
    	color: #468847;
    }
    #mailpoet_form_1 .mailpoet_validate_error {
    	color: #B94A48;
    }</style>
        <form
          method="post"
          action="https://www.sardegnavacanzelowcost.it/wp-admin/admin-post.php?action=mailpoet_subscription_form"
          class="mailpoet_form mailpoet_form_shortcode"
          novalidate
        >
          <input type="hidden" name="form_id" value="1" />
          <input type="hidden" name="token" value="xxxxxxxxxx" />
          <input type="hidden" name="endpoint" value="xxxxxxxx" />
          <input type="hidden" name="method" value="xxxxxxxxxxx" />
    
                <p class="mailpoet_paragraph">Voglio ricevere il report dei Costi che dovrò sostenere al mio arrivo nella struttura</p>
    <p class="mailpoet_paragraph"><label class="mailpoet_segment_label">Seleziona la Strutura Ricettiva che hai prenotato, di cui vuoi il riepilogo dei costi:</label><label class="mailpoet_checkbox_label"><input type="checkbox" class="mailpoet_checkbox" name="segments[]" value="3"  data-parsley-required="true" data-parsley-group="segments" data-parsley-errors-container=".mailpoet_error_segments" data-parsley-required-message="Please select a list" /> Cristal Blue</label><label class="mailpoet_checkbox_label"><input type="checkbox" class="mailpoet_checkbox" name="segments[]" value="5"  data-parsley-required="true" data-parsley-group="segments" data-parsley-errors-container=".mailpoet_error_segments" data-parsley-required-message="Please select a list" /> Costa del Turchese</label><label class="mailpoet_checkbox_label"><input type="checkbox" class="mailpoet_checkbox" name="segments[]" value="4"  data-parsley-required="true" data-parsley-group="segments" data-parsley-errors-container=".mailpoet_error_segments" data-parsley-required-message="Please select a list" /> Rena Majore</label><label class="mailpoet_checkbox_label"><input type="checkbox" class="mailpoet_checkbox" name="segments[]" value="7"  data-parsley-required="true" data-parsley-group="segments" data-parsley-errors-container=".mailpoet_error_segments" data-parsley-required-message="Please select a list" /> Villa Allegra Conca Verde</label><span class="mailpoet_error_segments"></span></p>
    <p class="mailpoet_paragraph"><label class="mailpoet_text_label">Email <span class="mailpoet_required">*</span></label><input type="email" class="mailpoet_text" name="email" title="Email" value="" data-parsley-required="true" data-parsley-error-message="Please specify a valid email address"/></p>
    <p class="mailpoet_submit"><input type="submit" value="Inviami il Report" /></p>
    
          <div class="mailpoet_message">
            <p
              class="mailpoet_validate_success"
                        style="display:none;"
                      >Report inviato! Controlla la tua mail in posta in arrivo o a volte nello spam</p>
            <p class="mailpoet_validate_error"
                        style="display:none;"
                      >        </p>
          </div>
        </form>
      </div>

     

could you help me to understand where is the error?

I have to say that the form is a mailpoet subscription form, and it is included into a sidebar and into the cart page of a booking process.

thanks