2017-11-22 15 views
0

누군가 아래의 서버 코드에서 인쇄 된 세 번째 줄이 'banana'라는 단어로 시작하지 않는 이유를 말해 줄 수 있습니까? 대신 빈 문자열을 반환합니다.JScript 변수 이상한

var conn; 

var g_itemid = 0; 

var sql = "select 1 as indx, 'apple' as vtype, 'red' as vcolor, 'Mac' as vmisc \ 
    union \ 
    select 1 as indx, 'apple', 'green', 'Mayberry' \ 
    union \ 
    select 2 as indx, 'banana', 'yellow', 'ripe' \ 
    union \ 
    select 2 as indx, 'banana', 'green', 'not ripe'"; 

if(connectToDatabase()==1) { 

    qs=conn.execute(sql); 

    while(!qs.eof) {   
     Response.Write(setItemText(qs("vtype"), qs("indx")) + "|" + qs("vcolor") + "|" + qs("vmisc")+ "<br>"); 
     qs.movenext(); 
    }   

    conn.Close(); 
    conn = null; 
} 

function setItemText(item, itemid) { 

    if(g_itemid!=itemid){ 
     g_itemid = itemid; 
     return item;    
    } 
    else {   
     return "";   
    }  
} 

답변

0

신경 쓰지 마세요. parseInt를 사용하여 전역을 설정해야합니다.