if else imacros with javascript command

时间:2018-04-21 08:20:04

标签: javascript if-statement imacros

请帮我写一下我的剧本 我想选中{{!COL22}} NOT NULL复选框,如果{{!COL22}}为NULL,则取消选中该复选框

但是此脚本在此语句中不适用于格式化条件

if (\"{{!COL22}}\" = "") {
        var uncheck = "CODE:";
        uncheck += "FRAME NAME=\"rf\"" + "\n";
        uncheck += "TAG POS=1 TYPE=LABEL ATTR=ONCLICK:publishVipJS.toggleSaleAttr(this,'text');&&FOR:testsale2260958&&DATA:9248:2260958&&TXT:" + "\n";
        uncheck += "TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:testsale2260958 CONTENT=NO" + "\n";
        iimset(uncheck);
        iimPlay(uncheck);
        var notif = alert("NULL");
    }else{
        var check = "CODE:";
        check += "FRAME NAME=\"rf\"" + "\n";
        check += "TAG POS=1 TYPE=LABEL ATTR=ONCLICK:publishVipJS.toggleSaleAttr(this,'text');&&FOR:testsale2260958&&DATA:9248:2260958&&TXT:" + "\n";
        check += "TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:testsale2260958 CONTENT=YES" + "\n";
        iimset(check);
        iimPlay(check);
        var notif = alert("SUCCSES");
    }

下面的完整脚本

var isi = "CODE:";
isi += "VERSION BUILD=8970419 RECORDER=FX" + "\n";
isi += "TAB T=1" + "\n";
isi += "SET !REPLAYSPEED FAST" + "\n";
isi += "SET !ERRORIGNORE YES" + "\n";
isi += "SET !TIMEOUT_PAGE 20" + "\n";
isi += "SET !TIMEOUT_STEP 0" + "\n";
isi += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
isi += "SET !DATASOURCE Shoes<SP>05-04-2018.csv" + "\n";
isi += "SET !LOOP 4" + "\n";
isi += "FRAME NAME=\"mainFrame\"" + "\n";
isi += "EVENT TYPE=CLICK SELECTOR=\"#mainContent>DIV:nth-of-type(29)>DIV>DIV>INPUT:nth-of-type(2)\" BUTTON=0" + "\n";
isi += "TAG POS=1 TYPE=INPUT:TEXT ATTR=TYPE:text&&ONCHANGE:publishVipJS.changeAlias(this,<SP>'text');&&VALUE:* CONTENT=" + "\n";
isi += "FRAME NAME=\"rf\"" + "\n";
isi += "TAG POS=101 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL22}}" + "\n";
isi += "FRAME F=0" + "\n";
isi += "TAG POS=1 TYPE=A ATTR=CLASS:btn" + "\n";
iimPlay(isi);

if (\"{{!COL22}}\" = "") {
    var uncheck = "CODE:";
    uncheck += "FRAME NAME=\"rf\"" + "\n";
    uncheck += "TAG POS=1 TYPE=LABEL ATTR=ONCLICK:publishVipJS.toggleSaleAttr(this,'text');&&FOR:testsale2260958&&DATA:9248:2260958&&TXT:" + "\n";
    uncheck += "TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:testsale2260958 CONTENT=NO" + "\n";
    iimset(uncheck);
    iimPlay(uncheck);
    var notif = alert("NULL");
}else{
    var check = "CODE:";
    check += "FRAME NAME=\"rf\"" + "\n";
    check += "TAG POS=1 TYPE=LABEL ATTR=ONCLICK:publishVipJS.toggleSaleAttr(this,'text');&&FOR:testsale2260958&&DATA:9248:2260958&&TXT:" + "\n";
    check += "TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:testsale2260958 CONTENT=YES" + "\n";
    iimset(check);
    iimPlay(check);
    var notif = alert("SUCCSES");
}

1 个答案:

答案 0 :(得分:0)

直接在js脚本中获取!COL22值是不可能的。您应该使用iim-code之前提取它。例如,通过使用其他宏:

...
iimPlay(isi);

iimPlayCode (
    'SET !DATASOURCE Shoes<SP>05-04-2018.csv' + "\n" +
    'SET !EXTRACT {{!COL22}}' + "\n"
);

if (iimGetExtract() = "") {
...