views:

217

answers:

1

I have a Problem with Jquery dropdown and Firefox.

Thats the situation: in the index.html there is a dropdown selection with 3 options. Each of theme has a html file. In the second dropdown there is again 3 Options after i select the first dropdown.

The Problem is in the second Dropdown. Firefox always takes the last from the file. Internet-Explorer just does it fine.

I hope someone can help me, and sorry because my english, :-S

i uploaded the files in a zip if anybody could help me... link

+1  A: 

Use a callback function to select the first drop-down option after loading the external content.

Modified index.html line 108:

$("select[name=ajax2]").load(datei + " option", null, ajax1Callback);

Add this to index.html line 126:

function ajax1Callback() {
    $('SELECT[name=ajax2]').val(0);
}
pygorex1
+1 This should fix your problem... also remove the `$("#ajax2").append(result).selectedIndex = 0;` - it's for an ID that doesn't exist and a `result` variable that is not defined.
fudgey
That was it. Greate, thank you. I was wondering if you also know, why the select option in the first dropdown can't load the extern code for the second dropdown. Only if i change in the first dropdown to a other option, than it works. That happens also if i go back in browser history, and i want to klick the option wich already is selected.
Bob
anybody? i was wondering if someone could help me
Bob
You could try setting a cookie with the user's selected value using `$.cookie`, then in `ajax1Callback()` set the val to the selected option.
pygorex1
hm how? Sorry i am new :-S could you explane that to me? Witch line, what code?
Bob
Using the JQuery cookie extension http://www.electrictoolbox.com/jquery-cookies/ you can save a cookie when a user makes a selection from a drop-down `('SELECT').click(function() { $.cookie('selected', $(this).val()); })` then check for the cookie in `ajax1Callback` like this `$('SELECT[name=ajax2]').val(0, $.cookie('selected'));`
pygorex1