add a Php drop down list to jquery

I’m populating a drop down list with page links in wordpress, see code below.

$html .= '<select id="pp_dropdown_link" name="hero_options[pp_dropdown_link_'.$i.']"> 
<option value="">' . attribute_escape(__('Select page')) . '</option> '; ?>
<?php 
    $pages = get_pages(); 
    foreach ($pages as $pagg) {
        $html .= '<option value="'.get_page_link($pagg->ID).'"' . selected( $hero_options['pp_dropdown_link_1'], ''.get_page_link($pagg->ID).'', false) . '>' . __( ''. $pagg->post_title .'' ) . '</option>';

            $html.= $pagg->post_title;

        $html .= '</option>';
    }
?>
<?php $html .= '</select>'; 
        $html .= '</div>';
        $i++;
    }
}
$html .= '</div><div class="button ppclone">Add an Image</div>';
echo $html; 

This is working fine when the page is saves but due to the form being cloned in jquery i need the drop down list in there.

Here’s my jquery code

var pptoappend='
<div id="ppclonedInput1" class="ppclonedInput">
  <input id="cs_product_menu_pp_src_1" type="text" size="36" name="hero_options[upload_pp_link_1]" value="" /><input id="cs_product_menu_pp_src_1_ppbutton" type="button" value="Add / Change" class="button-secondary pp-upload-button" />
<div class="button ppremove">-</div> 
<input id="pp_text_box1" class="pp_text_box" type="text" size="15" name="hero_options[pp_text_box_1]" value="" />
<select id="pp_dropdown_link" name="hero_options[pp_dropdown_link_1]">
  <option value=""></option>
</select>'

Any ideas?

Read more here: add a Php drop down list to jquery

Leave a Reply

Your email address will not be published. Required fields are marked *