Forum Moderators: open
e.g
var country = {
'73¢' : 'Afghanistan',
'28¢' : 'Albania',
'36¢' : 'Albania Mobile',
'27¢' : 'Algeria',
'9¢' : 'Andorra',
}
<form action="" name="rates">
<select class="country" onchange="thiswillswapthevalues();" name="main">
<option selected="selected">-Select from the list</option>
<script type="text/javascript">
for( var opt in country ){document.write( '<option value="' + opt + '">' + country [opt ] + '</option>' );}
</script>
</select>
</form>
But when it's outputted ,the select box( where the values are being placed into) are all over the place.
i was wondering if there is a way/line of code that would make the items retain their position in the array = country once in the select box?
Kind regards
o_trenseta_o
<script type="text/javascript">
var money = new Array();
var country = new Array();
money[0] = '73¢';
country[0] = 'Afghanistan';
money[1] = '28¢';
country[1] = 'Albania';
money[2] = '36¢';
country[2] = 'Albania Mobile';
money[3] = '27¢';
country[3] = 'Algeria';
money[4] = '9¢';
country[4] = 'Andorra';
</script>
<form action="" name="rates">
<select class="country" onchange="thiswillswapthevalues();" name="main">
<option selected="selected">-Select from the list</option>
<script type="text/javascript">
for( var i = 0; i < country.length; i++ ) { document.write( '<option value="' + money [i] + '">' + country [i] + '</option>' ) ; }
</script>
</select>
</form>