<li onClick="fill('#cpu', '2 x intel xeon e5462');">2 x intel xeon e5462</li>
<li onClick="fill('#cpu', '2 x intel qx9775');">2 x intel qx9775</li>
function fill(myid, value) {
$(myid).val(value);
$(myid + '-suggest').hide('slow');
}
can't help you but it does the same thing in google chrome, closes the list box.
the content of the box when it shows is simply....
Code:<li onClick="fill('#cpu', '2 x intel xeon e5462');">2 x intel xeon e5462</li> <li onClick="fill('#cpu', '2 x intel qx9775');">2 x intel qx9775</li>
and so on. the fill function is this...
Code:function fill(myid, value) { $(myid).val(value); $(myid + '-suggest').hide('slow'); }
this populates the text box on the form with the value you select and hides the list. that's all there is to it. i just don't know why it closes when you click on the scrollbar.![]()
$(document).ready(function()
{
// Stuff…
$('#cpu-list li').click(function()
{
fill('#cpu', $(this).text());
});
// More stuff…
});
function fill(id, value)
{
$(id).val(value);
$(id + '-suggest').hide('slow');
}
<ul id="cpu-list">
<li>2 x intel xeon e5462</li>
<li>2 x intel qx9775</li>
</ul>
Not sure about your original problem but you shouldn't be using onclick with jQuery. Instead, do something like:
Code:$(document).ready(function() { // Stuff… $('#cpu-list li').click(function() { fill('#cpu', $(this).text()); }); // More stuff… }); function fill(id, value) { $(id).val(value); $(id + '-suggest').hide('slow'); }
Code:<ul id="cpu-list"> <li>2 x intel xeon e5462</li> <li>2 x intel qx9775</li> </ul>
That way you don't end up polluting your markup with JavaScript.