Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

André C A Souza

[Resolvido] Valor de Input

Recommended Posts

[RESOLVIDO] http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif

 

Bom dia,

 

tenho a seguinte página e não estou conseguindo pegar o valor das texts.

 

<script type="text/javascript">
//<![CDATA[
function preencheLista(tab)
{
	var tabela	 = document.getElementById("tBody-lista");
	var ultima	 = tabela.rows.length;
	var linha	 = document.createElement("tr");
	linha.setAttribute("id","line"+ultima);
   
	var celula1	 = document.createElement("td");
	celula1.setAttribute('align','left');
	var cel1 = document.createElement("input");
	cel1.setAttribute('type', 'text');
	cel1.setAttribute('maxlenght', '10');
	cel1.setAttribute('size', '12');
	cel1.setAttribute('name','dt');
	cel1.setAttribute('id','dt');
	celula1.appendChild(cel1);
	linha.appendChild(celula1);
	
	var celula2 = document.createElement("td");
	celula2.setAttribute('align','left');
	var cel2 = document.createElement("input");
	cel2.setAttribute('type', 'text');
	cel2.setAttribute('maxlenght', '3');
	cel2.setAttribute('size', '3');
	cel2.setAttribute('name','pc');
	cel2.setAttribute('id','pc');
	celula2.appendChild(cel2);
	linha.appendChild(celula2);
	
	var celula3 = document.createElement("td");
	celula3.setAttribute('align','left');
	var cel3 = document.createElement("input");
	cel3.setAttribute('type', 'text');
	cel3.setAttribute('maxlenght', '10');
	cel3.setAttribute('size', '8');
	cel3.setAttribute('name','vl');
	cel3.setAttribute('id','vl');
	celula3.appendChild(cel3);
	linha.appendChild(celula3);
	
	var celula4	 = document.createElement("td");
	var link		= document.createElement('a');
	link.setAttribute('href','java script: void(0)');
	link.setAttribute('title','apagar');
	link.setAttribute('rel','line'+ultima);
	link.className	= 'link';
	link.onclick	= function()
	{
		document.getElementById("tBody-lista").removeChild(document.getElementById(this.getAttribute("rel")));
	};
	var img = document.createElement("img");
	img.setAttribute('src', '../estoque/img/bot_exc.png');
	img.setAttribute('border','0');
	link.appendChild(img);
	celula4.appendChild(link);
	linha.appendChild(celula4);
	tabela.appendChild(linha);
	}
		else
	{
	
	}
}
//]]>
<script>

 

<table width="304" cellpadding="0" cellspacing="0">
	<tbody id="tBody-lista">
		<tr>
			<td width="33%" align="left"><strong>DATA:</strong></td>
			<td width="32%" align="left"><strong>PORCENTAGEM</strong></td>
			<td width="29%" align="left"><strong>VALOR</strong></td>
			<td width="6%" align="left"><a href="java script: void(0)" onclick="preencheLista(1)"><img src="../estoque/img/bot_cad.png" border="0" /></a></td>
		</tr>
	</tbody>
</table>

como posso pegar o valor da text 'dt', por exempo?

Compartilhar este post


Link para o post
Compartilhar em outros sites

para você pegar o valor de um campo input

document.getElementById('dt').value

t+

Compartilhar este post


Link para o post
Compartilhar em outros sites

da para fazer isso sim!

 

em teoria e assim

w=document.getelementsByTagName("input"); // pega os elementos input
q=w.length; // pega quantos inputs;
z=new Array();

for(i=0;i<q;i++){ //percorre todos inputs
z[i]=w[i].value; // adiciona o valor do input de i ao array z
}

//para imprimir os valores e so fazer

for(k=0; k<z.length;k++){
document.write(z[k])
}

// imprime todos elementos do array

Nao tenho a certeza se esta a funfar pk nao testei mas experimente ae

 

editado por Otata 13:06 23/03

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.