Saturday, February 20, 2010

Programmer - Making a variable name a dynamic variable

Programmer Question

Hi There



I hope someone can help me with the following...



I have this code below it is written in classic asp and javascript...



I have this variable in the code below my2String1 how can I make this a dynamic variable like:




  • my2String1_1

  • my2String1_2

  • my2String1_3



I have a database value Recordset2.Fields.Item("article_no").Value which could be the dynamic value like:



my2String1_Recordset2.Fields.Item("article_no").Value (which should do the trick) but I am not sure how to implement it...



while((Repeat1__numRows-- != 0) && (!Recordset2.EOF)) { 
var my2String1 = ""+(Recordset2.Fields.Item("article_description").Value)+"";
my2String = my2String1;
var my2regexp = new RegExp(checkduplicates, "ig");
my2Array = my2String1.match(my2regexp);
my2length = my2Array.length;

for (i = 0; i < my2length; i++) {
my2Array[i] = '\''+my2Array[i]+'\'';
}

var arr = (myArray+my2Array).split(',');
var sorted_arr = arr.sort();
var results = [];

for (var i = 0; i < arr.length - 1; i += 1) {
if (sorted_arr[i + 1] == sorted_arr[i]) {
results.push(sorted_arr[i]);
}
}

Repeat1__index++;
Recordset2.MoveNext();
}


If you have any ideas on how to solve this please help me

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails