Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom dia, pessoal, tenho uma duvida que pode parecer meio confusa, por isso tentarei ilustrar tudo para que possam me ajudar. Tenho uma pagina, ilustrada pela imagem abaixo
cada formulário esta construido em uma linha de tabela conforme a codificaçao abaixo:
<tr id="pay$i">
<form action="processAjax.php" method="post" name="comrecs$i" id="comrecs$i" [b]onSubmit="processPayment (this, 'pay$i'); return false"[/b]>
<td>
$name
<input type="hidden" name="function" value="9"/>
<input type="hidden" name="id" value= "$id" />
<input type="hidden" name="indice" value= "$i" />
<input type="hidden" name="nparc" value= "$nparc" />
<input type="hidden" name="nome" />
</td>
<td>
<select id="clisegs" name="clisegs" onchange="SetApoliceValor('comrecs$i')"">
$selcli</select>
</td>
<td><input type="text" id="apolice" name="apolice" size="10"></td>
<td>$prev</td>
<td>$atual</td>
<td>
<input type="text" id="value" name="comIn" size="10" maxlength="16" onKeyPress="return ValidateValue (event, this);" onKeyUp="MaskValue (this, event, 16, 3)" />
</td>
<td>$npags/$nparc</td>
<td>
<input type="text" id="parcela" name="parcela" size="2">/<input type="text" id="tparc" name="tparc" size="2">
</td>
<td><input type="checkbox" name="cancelado" value="1"></td>
<td><input type="checkbox" name="quitado" value="1"></td>
<td id="ok">
<ul>
<li><input type="image" src="images/okp.png" alt="OK" /></li>
</ul>
</td>
</form>
</tr>
a função em destaque é a de processamento do ajax, que está abaixo
function processPayment (f, targ)
{
makeRequest();
var met = "\'" + f.method.toUpperCase() + "\'";
var act = f.action +"?";
var destiny = document.getElementById(targ);
var fields = "";
var tags;
var inputs;
for (var i=0; i<f.length; i++)
{
tags = f.elements[i].tagName.toUpperCase();
inputs = f.elements[i].type.toUpperCase();
if (tags == "INPUT" || tags == "SELECT" || tags == "TEXTAREA")
{
if (inputs == "FILE")
alert('ERRO: Não é possível enviar arquivos por AJAX');
if (inputs == "RADIO" || inputs == "CHECKBOX" )
{
if(f.elements[ i ].checked)
fields += f.elements[ i ].name + "=" + encodeURI(f.elements[ i ].value) + "&";
}
else
fields += f.elements[ i ].name + "=" + encodeURI(f.elements[ i ].value) + "&";
}
}
act += fields;
if (!ajax)
{
destiny.innerHTML = 'Impossível iniciar o objeto XMLHttpRequest.';
return;
}
else
destiny.innerHTML = 'Carregando...';
ajax.onreadystatechange = function ()
{
if (ajax.readyState == 4 || ajax.readyState == 0)
{
if (ajax.status == 200)
{
destiny.innerHTML = ajax.responseText;
}
else
destiny.innerHMTL = 'Página não encontrada!';
}
}
ajax.open (met, act, true);
ajax.setRequestHeader("Content-Type", "application/x-www-f-urlencoded");
ajax.send (fields);
}Carregando comentários...