03-08-2006, 13:54
|
|
|
חבר מתאריך: 17.05.05
הודעות: 7,321
|
|
אתה עושה מערך של מה שצריך להיות כתוב בתגי ה-option, סופר את כמות האיברים שיש במערך ואז בעזרת לולאת while כותב את הקוד שלך...
קוד:
var x = 0;
var output = '';
var info = new Array();
info[] = new Array('Value1', 'Id1', 'Text1');
info[] = new Array('Value2', 'Id2', 'Text2');
info[] = new Array('Value3', 'Id3', 'Text3');
info[] = new Array('Value4', 'Id4', 'Text4');
info[] = new Array('Value5', 'Id5', 'Text5');
/*
* The info array contains elements which contains another arrays
* that have information about the option tag attributes: value, id and text.
*/
while (x < info.length)
{
/* Code */
output .= '<option value=\''+info[x][0]+'\' id=\''+info[x][1]+'\'>'+info[x][2]+'</option>';
++x;
}
document.write(output);
נערך לאחרונה ע"י DCD בתאריך 03-08-2006 בשעה 13:58.
|