Hi,
I have a function in java script like this.I want to append a comma in reason_txts only if there is second element in array
function(result_arr){
var reason_ids="",reason_txts="";
for(i=0;i<result_arr.length;i++){
reason_ids+=result_arr[i].id+",";
reason_txts+=result_arr[i].col0+",";
}
document.getElementById("reasonIds_disp_hdn").value= reason_ids;
document.getElementById("appReason_text").value= reason_txts;
document.ViewSlot.appReason_text.className="txtbox2";
}
I tried like this,
function(result_arr){
var reason_ids="",reason_txts="";
for(i=1;i<=result_arr.length;i++){
reason_ids+=result_arr[i].id+",";
if(i == result_arr.length)
reason_txts+=result_arr[i].col0;
else
reason_txts+=result_arr[i].col0+",";
}
alert(reason_txts);
document.getElementById("reasonIds_disp_hdn").value= reason_ids;
document.getElementById("appReason_text").value= reason_txts;
document.ViewSlot.appReason_text.className="txtbox2";
}
but this alert itself not coming ---> alert(reason_txts);
Eg: if the input is a and b i want a,b in reason_txts
if the input ia a
i want a alone in reason_txts without any comma appended.
suggest me...