-2

So I was looking for an easy way(no use of database) to search items through a list with the help of a search bar.

I found this --- jsfiddle.net/TrRMG/90/

<input type="text" id="search">
<br>
<select id="customer" size="1">
  <option value=100>Alice</option>
  <option value=101>Bob</option>
  <option value=102>Carla</option>
  <option value=103>Dan</option>
  <option value=104>Eve</option>
</select>

Is there anyway to alter the code to make the searched items clickable?

Example:

Lets say I type in bob. Bob comes up in the second box, I click on it and it takes me to a page/website.

Is this possible? if so, how?

Jatin
  • 3,005
  • 6
  • 27
  • 42
Pbellum
  • 5
  • 3

1 Answers1

0

Something like this?

http://jsfiddle.net/TrRMG/107/

Added link="http://jsfiddle.net/TrRMG/107/" to each <option> tag and the following jQuery function

$('#customer option').click(function(){
    window.location='$(this).attr(link)'; 
});

It works kinda wonky because jsfiddle is working in iframes but implemented onto an actual page it should work just fine

Jake Ferrante
  • 28
  • 1
  • 5