jquery/IE problem

Perhaps relating to an onclick or onmousedown event somewhere? Seems to be a few scripts loading on the page. It seems to relating to the onclick event regardless of where you click in that windows it closes in IE.

Like you said FF is fine.
 
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. :p
 
I just thought that as it didn't work in both IE and chrome that it might help indicate a slightly different problem or something....I don't know I don't do this type of coding.
 
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. :p

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.
 
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.

thanks for that. i'm a complete noob at this and was simply using some code from a tutorial i found while googling. :o
 
well i've got that working on my main form which tidies up the html nicely. thanks. and it works with whole classes. sweet. :D

but it won't work on the list for some reason. not that it matters. you won't even see the code for that unless you're monitoring the console in firebug. :p
 
Last edited:
Back
Top Bottom