Note that there are some explanatory texts on larger screens.

plurals
  1. POBootstrap Typeahead Dropdown BR Tags
    primarykey
    data
    text
    <p>I am using the Bootstrap Typeahead - <a href="http://twitter.github.com/bootstrap/javascript.html#typeahead" rel="nofollow">http://twitter.github.com/bootstrap/javascript.html#typeahead</a> functionality to predict text in an input box.</p> <p>I was wondering in the dropdown (that shows the predictive results) I could display each of the dropdown items on two lines. Suppose I am trying to predictive search between Organizations, but I also wanted to display the President of the Organization. How would I go about doing this.</p> <p>I attempted to solve this problem in the following code. It displays the dropdown items on two lines showing both Organization and President. However when I select one of the dropdowns the "BR tag" shows up in my input text field. How would I fix this? Thanks</p> <pre><code>&lt;?php $db = new mysqli('localhost', 'root' ,'', 'test'); $query = $db-&gt;query("SELECT name,leader FROM organizations"); $orgs = array(); while($row = $query-&gt;fetch_array(MYSQLI_ASSOC)){ $orgs[] = $row['name'].'&lt;br /&gt;'.$row['leader']; } $js_orgs = json_encode($orgs); if($_POST){ print_r($_POST); } ?&gt; &lt;html&gt; &lt;head&gt; &lt;link href="bootstrap.css" rel="stylesheet" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;form method="post" action="demo.php"&gt; &lt;input name="org" type="text" class="span3" id="search" /&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="bootstrap.min.js"&gt;&lt;/script&gt; &lt;script&gt; var subjects = &lt;?php echo $js_orgs; ?&gt;; $('#search').typeahead({source: subjects, items:6}) &lt;/script&gt; </code></pre> <p> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload