views:

148

answers:

3

Hello everybody!

Im writing a admin panel for a customer's sites, and at few places, i need to put a list of country. He want's to get Canada and US in first place, because his market are mainly US and Canada.

So, i write something like that :

<select name="customerCoutry">  
    <option value="US">United States</option>
    <option value="CA">Canada</option>
    <option value="FR">France</option>
    [...]
</select>

In Firefox and Internet Explorer, it's look nice, i have a drop down with US in first place, Canada in second place, France in third place, ...

But in Safari, it's place the country name in alphabetical order. So i have a lot of Countrys (Autralia, ....), Canada, (other ones), France, (a lot of other ones) United States, (finally the others). Do you know if a hack exist to allow us to disable this Safari Feature? For example, <select name="customerCoutry" soriting="none">, a special meta tag, something else i can insert in my page?

Thank you for your help!

...and sorry for my bad English, this is not my first language :S

+1  A: 

I've tested this in Safari on my machine, and it works fine. What version of Safari are you using?

Don Werve
I use Safari 3.2.1 (5525.27.1) for mac.
+1  A: 

I've also tested it in Safari and it works fine. If this is still a problem, check to see whether the alphabetical ordering is based on option value or option label; if it's on option value, just number the values, e.g. "0US", "1CA" etc. If it is based on the actual selection label, then you may have to number the labels.

Perspx
A: 

Finally i have found the problem, and unfortunately, the answer don't fit really with the question (do you think i need to edit it to help the others users?).

The problem was the following. I send through ajax a array parsed in Json of country's, ordered by the order i want to display it.

[{"CountryID":"37","CountryCode":"CA","CountryName":" Canada"},{"CountryID":"229","CountryCode":"US","CountryName":"United States"},[...]

I receive this (long) array and i add it to an array where the key are the CountryID are the ID of the country record in the database, and roughly, this ID seems to have almost the same order as the alphabetical order. The issue happens when i browse the array with a for ( item in countryArray ) {...} loop. Safari seems to browse each item in a sorted order, instead of Firefox where it's browse each item in the order of the added elements.

Thank you for your help! Especially Perspx, it's your answer have given to me the hint to find a solution (and the right problem). :)

Thank you again and have a good week-end!