Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $rd_args = (array(
- 'ignore_sticky_posts' => 1,
- 'orderby' => 'meta_value',
- 'order' => 'ASC',
- 'meta_query' => array(
- array(
- 'key' => 'brand',
- ),
- array(
- 'key' => 'model',
- )
- )
- ));
- $rd_query = new WP_Query( $rd_args );
- $the_query = new WP_Query(array( 'meta_key' => 'votes_count', 'meta_value' => '1' ));
- $html_out = '';
- $html_out = '<select id="office-chooser2" >';
- $html_out .= '<option value="none">Select an Office</option>';
- $select = '<select id="office-chooser">';
- $select .= '<option value="none">Select an Office</option>';
- while ($rd_query->have_posts()) : $rd_query->the_post();
- // add each div with excerp. It's ID is unique and correlates to value of select drop down
- $brand = (get_post_meta($post->ID, 'brand', true));
- $model = (get_post_meta($post->ID, 'model', true));
- $html_out .= '<option value="office-'.$post->ID.'" class="office-entry" id="office-'.$post->ID.'">'.$model.'</option>';
- $select .= '<option value="office-'.$post->ID.'">'.$brand.'</option>';
- endwhile;
- // wrap up $select
- $select .= '</select>';
- $html_out .= '</select>';
- echo $select;
- echo $html_out;
- ?>
- <script type="text/javascript">
- jQuery(function($){
- $('#office-chooser').change(function(){
- var $selected_office = $(this).val();
- if(($selected_office == 'none') ){
- $('div.office-entry').hide();
- $('#office-chooser2').hide();
- $('#' + $selected_office).hide();
- } else {
- $('#' + $selected_office).show();
- $('#office-chooser2').show();
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement