R
Rahul
Hello ,
I have a JS sorting issue with a drop down . Scenario is that data is
coming in a sorted way through ajax , this data is then populated
using new option method
Now when the data is been rendered to the HTML page it is not in
sorted form . pls refer to the code below:
function ___populate_states(str, element)
{
eval(str);
alert(element);
//prints
states_array = new Array();
states_array['2'] = 'Delhi';
states_array['5'] = 'Karnataka';
states_array['3'] = 'Maharashtra';
states_array['4'] = 'Uttar Pradesh';
//
for (index = 1; index < element.options.length; index = index + 1)
{
element.options[index] = null;
}
element.options.length = 1;
var index = 1;
if (typeof(states_array) != 'undefined')
{
for (key in states_array)
{
element.options[index++] = new Option(states_array[key], key);
}
}
}
Please help.
I have a JS sorting issue with a drop down . Scenario is that data is
coming in a sorted way through ajax , this data is then populated
using new option method
Now when the data is been rendered to the HTML page it is not in
sorted form . pls refer to the code below:
function ___populate_states(str, element)
{
eval(str);
alert(element);
//prints
states_array = new Array();
states_array['2'] = 'Delhi';
states_array['5'] = 'Karnataka';
states_array['3'] = 'Maharashtra';
states_array['4'] = 'Uttar Pradesh';
//
for (index = 1; index < element.options.length; index = index + 1)
{
element.options[index] = null;
}
element.options.length = 1;
var index = 1;
if (typeof(states_array) != 'undefined')
{
for (key in states_array)
{
element.options[index++] = new Option(states_array[key], key);
}
}
}
Please help.