0
I am using jQuery to create a search field with "autocomplete" that is working perfectly. However, I am unable to direct to the link, when the user selects.
My code is like this:
<head>
<link rel="stylesheet" href="libraries/jquery-ui.css">
<script type="text/javascript" src="libraries/jquery.js"></script>    
</head>
<div id="pesquisa" style="float: right; margin-top: 45px; margin-right: 10px;">  
   <form action="index.php?id=<?php echo $linha["id"]; ?>&tp=total" method="get" name="autocomplete" target="_self">
      <input id="autocomplete" title="Digite algo">   <button id="button-icon">.</button>
   </form>
</div><!--pesquisa-->
<script src="libraries/jquery.js"></script>
<script src="libraries/jquery-ui.js"></script>
<script>
<?php
    $sql = "SELECT 
    pags.title, 
    pags.keywords, 
    pags.tema
    FROM pags
    ORDER BY pags.id";
    $resultado = $PDO->query( $sql );
    $rows = $resultado->fetchAll(PDO::FETCH_ASSOC);
?>
    var availableTags = [
<?php
    foreach ($rows as $key => $linha) {
    echo '"' . $linha['title'] .' | ' . $linha['keywords'] . '",';
    }       
?>
    ""
    ];
    $( "#autocomplete" ).autocomplete({
    source: availableTags
    });
    $( "#button" ).button();
    $( "#button-icon" ).button({
    icon: "ui-icon-gear",
    showLabel: false
    });
</script>               
Where are the links and how would this redirection be done? The question is very vague.
– Sam
The link is in the form action
– Webster Moitinho
Ok, but that’s when you click the button next to the field or when the user clicks on a list option?
– Sam
When you click the button. But I can’t do either...
– Webster Moitinho