问题
i am not sure where to start. i have a website where data is stored in list box controls. If i use "TXTALL" tag i can save list values.
1st step is to collect list of "_s_brand" manufacturers and store it in a array 2nd step is to collet 2nd level families - "_s_name" and store it in arrany for each "_s_brand" manufacturer 3rd step is to collect series for each "_s_brand" and for each "_s_name" 4th step is to final setp is for each "_s_brand" and for each "_s_name" and for each collect "_s_model" values
started script as below.
var jsLF = "\n";
var macro1;
macro1 = "CODE:";
macro1 += "VERSION BUILD=9002379" + jsLF;
macro1 += "TAB T=1" + jsLF;
macro1 += "TAB CLOSEALLOTHERS" + jsLF;
macro1 += "URL GOTO=http://smartparts.co.uk/" + jsLF;
macro1 += "TAG POS=1 TYPE=SELECT FORM=ACTION:/catalog/?left_selector=1 ATTR=NAME:brand EXTRACT=TXTALL"
var s_brand = new Array()
iimPlay("CODE:TAG POS=1 TYPE=SELECT FORM=ACTION:/catalog/?left_selector=1 ATTR=NAME:brand EXTRACT=TXTALL");
if (iimGetLastExtract()!='#EANF#')
s_brand.push(iimGetLastExtract());
iimDisplay (s_brand);
it is dumping all data into the array. how to seperate elements here so that if i loop "s_brand" i will get individual brands.
after i seperate how do i use them to go to next level of sub category
回答1:
For this you have to use JS.
Useful features are.
s_brand=s_brand .toString();
This way you can convert array into string and do methods like
split()
replace()
match()
search()
When you look into the array as a text you can use split() on _s_brand
and get brands.
And try to use this method
//convert text into array
some_array=some_array.split("keyword");
//loop through array
for(var i = 0; i < some_array.length ; i++)
{
//do something
alert(some_array[i]);
}
Combining the above and regular expressions you can extract what you want form the text.
I hope this helps.
来源:https://stackoverflow.com/questions/20152815/can-we-do-this-imacros-javascript-for-listbox-values-of-website-multi-level-cate