2012-09-25, 03:44 AM
Hello. I am working with a Tag system. When User Wants to post a thread, He is asked to enter some tags. I want the Tag Text box to be autocomplete.
Firstly here is the code that I have put inside new thread template
<input type="text" class="textbox" name="tags" id="tags" value="" autocomplete="on"/>
<script type="text/javascript" src="{$settings['bburl']}/jscripts/autocomplete.js?ver=1600"></script>
<script type="text/javascript">
<!--
if(use_xmlhttprequest == "1")
{
new autoComplete("tags", "{$settings['bburl']}/xmlhttp.php?action=get_tags", {valueSpan: "tags"});
}
// -->
</script>
Now I updated xmlhtp and added one else if section to handle get_tags
But autocomplete is not performed. Can you please suggest where I am doing wrong?
My site:http://grasshoppernetwork.com
Firstly here is the code that I have put inside new thread template
<input type="text" class="textbox" name="tags" id="tags" value="" autocomplete="on"/>
<script type="text/javascript" src="{$settings['bburl']}/jscripts/autocomplete.js?ver=1600"></script>
<script type="text/javascript">
<!--
if(use_xmlhttprequest == "1")
{
new autoComplete("tags", "{$settings['bburl']}/xmlhttp.php?action=get_tags", {valueSpan: "tags"});
}
// -->
</script>
Now I updated xmlhtp and added one else if section to handle get_tags
else if($mybb->input['action'] == "get_tags")
{
// If the string is less than 3 characters, quit.
if(my_strlen($mybb->input['query']) < 3)
{
exit;
}
// Send our headers.
header("Content-type: text/plain; charset={$charset}");
// Sanitize the input.
$mybb->input['query'] = str_replace(array("%", "_"), array("\\%", "\\_"), $mybb->input['query']);
// Query for any matching usergroups.
$query_options = array(
"order_by" => "tags",
"order_dir" => "asc",
"limit_start" => 0,
"limit" => 15
);
$query = $db->simple_select("tags", "aid", "tags LIKE %'".$db->escape_string($mybb->input['query'])."%'", $query_options);
while($group = $db->fetch_array($query))
{
$group['tags'] = htmlspecialchars_uni($group['tags']);
// Send the result to the browser for this usergroup.
echo "<div>\n";
echo "<span class=\"tags\">{$group['tags']} (Tags {$group['tags']})</span>\n";
echo "</div>\n";
}
}
But autocomplete is not performed. Can you please suggest where I am doing wrong?
My site:http://grasshoppernetwork.com