如何在所有页面上使自动完成工作

时间:2019-01-28 07:10:37

标签: php autocomplete

请帮助。我创建自动完成。但并非在所有页面上都有效。某些页面正常工作,某些页面无效。请帮助

print '
<input type="text" autocomplete="off" id="adv_location" class="form-control" name="adv_location"  placeholder="'.esc_html__('Ketik Lokasi','core').'" value="">      
                        ';


$availableTags='';
$args = array(
    'orderby' => 'count',
    'hide_empty' => 0,
); 

$terms = get_terms( 'property_city', $args );
foreach ( $terms as $term ) {
   $availableTags.= '"'.$term->name.'",';
}

$terms = get_terms( 'property_area', $args );

foreach ( $terms as $term ) {
   $availableTags.= '"'.$term->name.'",';
}

print '
<input type="text" autocomplete="off" id="adv_location" class="form-control" name="adv_location"  placeholder="'.esc_html__('Ketik Lokasi','core').'" value="">      
                        ';
                        
                        
$availableTags='';
$args = array(
    'orderby' => 'count',
    'hide_empty' => 0,
); 

$terms = get_terms( 'property_city', $args );
foreach ( $terms as $term ) {
   $availableTags.= '"'.$term->name.'",';
}

$terms = get_terms( 'property_area', $args );

foreach ( $terms as $term ) {
   $availableTags.= '"'.$term->name.'",';
}

$terms = get_terms( 'property_county_state', $args );
foreach ( $terms as $term ) {
   $availableTags.= '"'.$term->name.'",';
}

 print '<script type="text/javascript">
                       //<![CDATA[
                       jQuery(document).ready(function(){
                            var availableTags = ['.$availableTags.'];
                            jQuery("#adv_location").autocomplete({
                                source: availableTags,
                                
                                change: function() {
                                    wpestate_show_pins();
                                }
                            });
                       });
                       //]]>
                       </script>';
print '
<input type="text" autocomplete="off" id="adv_location" class="form-control" name="adv_location"  placeholder="'.esc_html__('Ketik Lokasi','core').'" value="">      
                        ';
                        
                        
$availableTags='';
$args = array(
    'orderby' => 'count',
    'hide_empty' => 0,
); 

$terms = get_terms( 'property_city', $args );
foreach ( $terms as $term ) {
   $availableTags.= '"'.$term->name.'",';
}

$terms = get_terms( 'property_area', $args );

foreach ( $terms as $term ) {
   $availableTags.= '"'.$term->name.'",';
}

$terms = get_terms( 'property_county_state', $args );
foreach ( $terms as $term ) {
   $availableTags.= '"'.$term->name.'",';
}

 print '<script type="text/javascript">
                       //<![CDATA[
                       jQuery(document).ready(function(){
                            var availableTags = ['.$availableTags.'];
                            jQuery("#adv_location").autocomplete({
                                source: availableTags,
                                
                                change: function() {
                                    wpestate_show_pins();
                                }
                            });
                       });
                       //]]>
                       </script>';

 print '<script type="text/javascript">
                       //<![CDATA[
                       jQuery(document).ready(function(){
                            var availableTags = ['.$availableTags.'];
                            jQuery("#adv_location").autocomplete({
                                source: availableTags,

                                change: function() {
                                    wpestate_show_pins();
                                }
                            });
                       });
                       //]]>
                       </script>';

0 个答案:

没有答案