Webskater
12-01-2003, 09:26 AM
I have two arrays thus:
var UserIDAry = new Array();
var UserNameAry = new Array();
These might be populated like this:
UserIDAry[0] = 0
UserIDAry[1] = 1
UserIDAry[2] = 2
UserNameAry[0] = 'Zak'
UserNameAry[1] = 'Norman'
UserNameAry[2] = 'Arthur'
Which means Zak has a UserID of 0, Norman has a UserID of 1 and Arther has a UserID of 2.
I want to populate a select box with the two arrays - to show the names and put the IDs as the values in the option tags. Can anyone tell me how I sort the UserNameAry so that it displays in alphabetical order (ascending)? ...
... and how can I sort the UserIDAry so that the right values are shown against the right people so it will look like ...
<select>
<option value=2>Arthur</option>
<option value=1>Norman</option>
<option value=0>Zak</option>
</select>
Thanks for any help. (I have my own reasons for not putting them both in the same array).
var UserIDAry = new Array();
var UserNameAry = new Array();
These might be populated like this:
UserIDAry[0] = 0
UserIDAry[1] = 1
UserIDAry[2] = 2
UserNameAry[0] = 'Zak'
UserNameAry[1] = 'Norman'
UserNameAry[2] = 'Arthur'
Which means Zak has a UserID of 0, Norman has a UserID of 1 and Arther has a UserID of 2.
I want to populate a select box with the two arrays - to show the names and put the IDs as the values in the option tags. Can anyone tell me how I sort the UserNameAry so that it displays in alphabetical order (ascending)? ...
... and how can I sort the UserIDAry so that the right values are shown against the right people so it will look like ...
<select>
<option value=2>Arthur</option>
<option value=1>Norman</option>
<option value=0>Zak</option>
</select>
Thanks for any help. (I have my own reasons for not putting them both in the same array).