<fieldset id="category-fields"> <div class="featured-head"><h3><?php _e( 'Listing type', APP_TD ); ?></h3></div> <div class="form-field"><label> <?php _e( 'Category', APP_TD ); ?> <?php wp_dropdown_categories( array( 'taxonomy' => VA_LISTING_CATEGORY, 'hide_empty' => false, 'hierarchical' => true, 'name' => VA_LISTING_CATEGORY, 'selected' => $listing->category, 'show_option_none' => __( 'Select Category', APP_TD ), 'class' => 'required' ) ); ?> </label></div>
<script language="JavaScript" type="text/javascript"> <!-- /* - Give Credit Where Its Due - Please acknowledge this article and its author, at least in code comments, when using this code. Thank you. Justin Whitford http://www.whitford.id.au/webmonkey/code/dropdown.php */ /* filtery(pattern, list) pattern: a string of zero or more characters by which to filter the list list: reference to a form object of type, select Example: <form name="yourForm"> <input type="text" name="yourTextField" onchange="filtery(this.value,this.form.yourSelect)"> <select name="yourSelect"> <option></option> <option value="Australia">Australia</option> ....... */ function filtery(pattern, list){ /* if the dropdown list passed in hasn't already been backed up, we'll do that now */ if (!list.bak){ /* We're going to attach an array to the select object where we'll keep a backup of the original dropdown list */ list.bak = new Array(); for (n=0;n<list.length;n++){ list.bak[list.bak.length] = new Array(list[n].value, list[n].text); } } /* We're going to iterate through the backed up dropdown list. If an item matches, it is added to the list of matches. If not, then it is added to the list of non matches. */ match = new Array(); nomatch = new Array(); for (n=0;n<list.bak.length;n++){ if(list.bak[n][1].toLowerCase().indexOf(pattern.toLowerCase())!=-1){ match[match.length] = new Array(list.bak[n][0], list.bak[n][1]); }else{ nomatch[nomatch.length] = new Array(list.bak[n][0], list.bak[n][1]); } } /* Now we completely rewrite the dropdown list. First we write in the matches, then we write in the non matches */ for (n=0;n<match.length;n++){ list[n].value = match[n][0]; list[n].text = match[n][1]; } for (n=0;n<nomatch.length;n++){ list[n+match.length].value = nomatch[n][0]; list[n+match.length].text = nomatch[n][1]; } /* Finally, we make the 1st item selected - this makes sure that the matching options are immediately apparent */ list.selectedIndex=0; } // --> </script> <fieldset id="category-fields"> <div class="featured-head"><h3><?php _e( 'Listing type', APP_TD ); ?></h3></div> <div class="form-field"><label>Search <input type="text" name="categorySearch" onkeyup="filtery(this.value,this.form.listing_category)" onchange="filtery(this.value,this.form.listing_category)"> </label></div> <div class="form-field"><label> <?php _e( 'Category', APP_TD ); ?> <?php wp_dropdown_categories( array( 'taxonomy' => VA_LISTING_CATEGORY, 'hide_empty' => false, 'hierarchical' => false, 'name' => VA_LISTING_CATEGORY, 'selected' => $listing->category, 'show_option_none' => __( 'Select Category', APP_TD ), 'class' => 'required', 'orderby' => 'name', 'order' => 'ASC' ) ); ?> </label></div>
There are currently 1 users browsing this thread. (0 members and 1 guests)