Ir para conteúdo

POWERED BY:

Arquivado

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

Mr Crowley

Saber o tipo de campo, se é imput, select, radio, check

Recommended Posts

ola pessoal

preciso saber como eu faço pra descobrir qual o tipo do campo

se ele é imput, select, radio, check, button e assim por diante

é necessario que funcione no FF e IE

 

consegui fazer essa função

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><form id="form" name="form" method="post" action="linkget.html" onsubmit="LinkGet('Texto,Lista,Check,Radio')">  <table width="300" border="0" cellspacing="0" cellpadding="0">	<tr>	  <td>Texto</td>	  <td><input name="Texto" type="text" id="Texto" value="nome val" size="20" maxlength="20" /></td>	</tr>	<tr>	  <td>Select</td>	  <td><select name="Lista" id="Lista">		<option value="0"></option>		<option value="um" selected="selected">1</option>		<option value="dois">2</option>		<option value="tres">3</option>	  </select>	  </td>	</tr>	<tr>	  <td>Check</td>	  <td><input name="Check" type="checkbox" id="Check" value="1" /></td>	</tr>	<tr>	  <td>Radio</td>	  <td><input name="Radio" type="radio" value="1" checked="checked" />	  <input name="Radio" type="radio" value="2" /></td>	</tr>	<tr>	  <td> </td>	  <td> </td>	</tr>	<tr>	  <td colspan="2"><input type="submit" name="Submit" value="Submit" /></td>	</tr>  </table></form></body></html><script language="javascript">function LinkGet(LinkNome){	var LinkNomeArray = LinkNome.split(",");	var Link;	var i = 0;	while (i<LinkNomeArray.length){		alert('Nome do campo = ' + LinkNomeArray[i]);		alert('Valor do campo = ' + document.getElementById(LinkNomeArray[i]).value);		alert('Tipo do campo = ' + document.getElementById(LinkNomeArray[i]).getAttribute("type"));		i = i + 1;	}	}</script>

porem no FF ele me retorna NULL no select

alguem sabe da cura pra isso?

 

falow

T+ pessoal

Compartilhar este post


Link para o post
Compartilhar em outros sites

o objeto select naum tem o atributo type por isso está retornando nullthe void

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.