0

My php script uses mysql results to create a dynamic combo box which then submits back to the script to process the selections. Basically the combo box options are created with this loop:

foreach ($attachments as $value) {echo '<option value="' . $value . '" selected>' . $value . '</option>';}

I'd like to filter that combo box using jquery so I tried messing around with the plugin jquery.livefilter. It works great if the data is encased in <li> tags like this:

<ul id="livefilter-list">
  <li><a href="#">cool</a></li>
  <li><a href="#">nice</a></li>
  <li><a href="#">interesting</a></li>
  <li><a href="#">javascript</a></li>
  <li><a href="#">css</a></li>
  <li><a href="#">html</a></li>
  <li><a href="#">script</a></li>
  <li><a href="#">international</a></li>
</ul>

But can I somehow use my combo box's option tag instead of the list tag? Is there another way to filter option tags with jquery?

Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
Geo316
  • 33
  • 8
  • 1
    This is a duplicate of this question: http://stackoverflow.com/questions/1447728/how-to-dynamic-filter-options-of-select-with-jquery – Precastic Jun 13 '13 at 19:23
  • Yes it is! And thanks - I did search before posting but didn't see this. I found my answer there. – Geo316 Jun 14 '13 at 13:32

1 Answers1

0
echo "<select id='myOptions'>";
foreach ($attachments as $value) {
    echo '<option value="' . $value . '">' . $value . '</option>';
}
echo "</select>";

Not sure why you want them all to be selected

RST
  • 3,899
  • 2
  • 20
  • 33