Monday, May 30, 2011

[phpXperts] Need help for js array

 

Hello Experts,

I am a new user of jquery. Can anyone help me solving the following:

I have the following javascript array:

var mylist = new Array();
    mylist[0][0] = 'value1';
    mylist[0][1] = 'value11';
   
    mylist[1][0] = 'value2';
    mylist[1][1] = 'value22';
   
    mylist[2][0] = 'value3';
    mylist[2][1] = 'value33';
   
    mylist[3][0] = 'value4';
    mylist[3][1] = 'value44';
   
    mylist[4][0] = 'value5';
    mylist[4][1] = 'value55';

I want to populate options of a select element with these values with jquery, like below:

<select name="myselect">
  <option value="value1">value11</option>
  <option value="value2">value22</option>
  <option>...........
</select>

I tried $.each(), but could not make it.


Regards,
Rahat Bashir

__._,_.___
Recent Activity:
Visit phpXperts website at www.phpxperts.net
MARKETPLACE

Get great advice about dogs and cats. Visit the Dog & Cat Answers Center.


Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

No comments: