public static function input_category($TrCategoryDefault) { $CategoryArrayDesc = db_function::category_select_distinct(); array_unshift($CategoryArrayDesc, "None"); echo "<div class='form-group'>"; echo "<label for='Category'>Category</label>"; echo "<input id='Category' type='text' name='Category' class='form-control' placeholder='Choose a category' autocomplete = 'off' required />"; echo "<span class='help-block'></span>"; echo "</div>\n"; echo "<script type='text/javascript'>"; echo "var CategoryList = " . json_encode($CategoryArrayDesc) . ";"; echo "\$('#Category').typeahead({hint: true, highlight: true, minLength: 1},{name: 'CategoryList', displayKey: 'value',source: substringMatcher(CategoryList)});"; if ($TrCategoryDefault != "") { echo "document.getElementById('Category').value='{$TrCategoryDefault}';"; } echo "</script>"; }