Reading some comments and especially comments from colleague TobyMosque, I try today to avoid using eval (). Well, now comes the next. In simple expressions, how do I replace it? See below a variable declaration that I got here on the system I work on and see if my approach is correct? Due to a problem we had here today, I'm not able to test and in jsfiddle it does not, because the page has lots of asp call and is extremely large, as there is dependence on other pages.
function prorrogaVencimento(pLinha) {
var intI = pLinha;
var v_num_seq_cobranca = eval('form01.num_seq_cobranca_' + intI + '.value');
var v_nom_tipo_ciclo = eval('form01.nom_tipo_ciclo_' + intI + '.value');
var v_txt_num_linha_digitavel = eval('form01.num_linha_digitavel_' + intI + '.value');
var v_num_seq_fatura_ts = eval('form01.num_seq_fatura_ts_' + intI + '.value');
var v_ind_tipo_cobranca = eval('form01.ind_tipo_cobranca_' + intI + '.value');
var v_mes_ano_ref = eval('form01.mes_ano_ref_' + intI + '.value');
var v_ind_situacao = eval('form01.ind_situacao_' + intI + '.value');
if ((v_ind_tipo_cobranca == '5' || v_ind_tipo_cobranca == '6') & v_ind_situacao == 'Vencidas' {
alert('Ação não permitida para o tipo da cobrança.');
return;
}
I did it, but I think it's bad:
var v_num_seq_cobranca = eval('form01.num_seq_cobranca_' + intI + '.value');
for this:
var v_num_seq_cobranca = form01.num_seq_cobranca_[intI].value;
You have this other approach too:
var v_num_seq_cobranca = window['form01.num_seq_cobranca_' + intI].value;