I have a function in JavaScript that includes a line with several input types (texts and buttons), using innerHTML
.
I've added another% w / o to this function, and I needed to use a classic ajax to include within the div
values that return from a search, and this div
only appears when a certain field is populated.
Until then it works beauty .. but when I go to do the process in the second line the first div
disappears and also does not appear the data in the second line.
I think it's because all div
have the same name, and I'm not able to create div with different names at the time the new line is added.
Code:
function NovaLinha_Trip(js_fornec, js_cd_pessoa, js_ds_pessoa, js_cd_acordo, js_ds_acordo) { if (js_fornec == 16) { v_fornec = 1; } else { v_fornec = js_fornec; } var js_pos = document.forms[0].prc_ds_pessoa.length; var vdiv = document.createElement("div"); vdiv.id = "acomtrip" + js_pos; alert(js_pos + vdiv.id); if (js_click == "S") { return } if (js_cd_pessoa == undefined) { js_cd_pessoa = ""; } if (js_ds_pessoa == undefined) { js_ds_pessoa = ""; } if (js_cd_acordo == undefined) { js_cd_acordo = ""; } if (js_ds_acordo == undefined) { js_ds_acordo = ""; } oRow = eval("oTableTrechoBody" + js_fornec).insertRow(-1); oCell = oRow.insertCell(-1); oCell.innerHTML = ''; oCell = oRow.insertCell(-1); oCell.innerHTML = ''; if (js_fornec == 16) { oCell = oRow.insertCell(-1); oCell.innerHTML = ''; oCell = oRow.insertCell(-1); oCell.innerHTML = ' '; } else { oCell = oRow.insertCell(-1); oCell.innerHTML = ''; } oCell = oRow.insertCell(-1); oCell.innerHTML = ''; oCell = oRow.insertCell(-1); oCell.innerHTML = ''; oCell = oRow.insertCell(-1); oCell.innerHTML = ''; oCell = oRow.insertCell(-1); oCell.innerHTML = ''; oCell = oRow.insertCell(-1); oCell.innerHTML = ''; } function carregaServico(js_campo) { alert('js_campo ' + js_campo.value); // mesmo comenttando a linha js_campo.disabled o problema persiste js_campo.disabled = true; alert('js_campo ' + js_campo); var js_array = js_busca_indice_array(js_campo); alert('js_array ' + js_array); var vpes = eval("document.forms[0].prc_cd_pessoa[" + js_array + "]").value; var vtip = eval("document.forms[0].prc_cd_tipo_fornecedor[" + js_array + "]").value; var vaco = eval("document.forms[0].prc_cd_acordo[" + js_array + "]").value; alert('vpes ' + vpes); if (vpes != "") { var url = "prc_lista_servico?prc_cd_pessoa=" + vpes + "&prc_cd_tipo_fornecedor=" + vtip + "&prc_cd_acordo=" + vaco; new Ajax.Request(url, { method: "get", onSuccess: function (transport) { document.getElementById("acomtrip").innerHTML = transport.responseText; document.forms[0].prc_chk_tipo_servico[" + js_array + "].focus(); }, onFailure: function () { alert("Problemas ao carregar os tipos de serviços") } }); } }