vbscript - Using replace with some kind of loop? -
i have variable following values:
variable1 = "apple, banana, pineaple, grape, coconut"
i use replace
following result:
variablex = "<span class="text1">apple</span> <span class="text2">banana</span> <span class="text1">pineapple</span> <span class="text2">grape</span> <span class="text1">coconut</span>"
so, first value gets text1
, second gets text2
, third gets text1
, forth gets text2
, on, until end.
' split array... = split(variable1, ",") ' add each element <span> tag... = 0 ubound(a) variablex = variablex & "<span class=""text" & + 1 & """>" & trim(a(i)) & "</span>" next
update respect comments:
to alternate between 2 values can put them in array , use mod
alternatively select 1 of values.
a = split(variable1, ",") strclasses = array("text-info", "text-warning") ' add each element <span> tag... = 0 ubound(a) variablex = variablex & "<span class=""" & strclasses(i mod 2) & """>" & trim(a(i)) & "</span>" next
Comments
Post a Comment