Ir para conteúdo

POWERED BY:

Arquivado

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

marvi

função

Recommended Posts

Pessoal estou usando a seguinte função

 

onchange="RetornoAjax(this.value, this.text, 'estados.asp', 'estados')" Vejam o This.text

 

Função

 

function RetornoAjax(id, txt, url, container)
{
	if (id == "")
	{
		document.getElementById("estados").innerHTML = "<select></select>";
		document.getElementById("cidades").innerHTML = "<select></select>";
		document.getElementById("zona").innerHTML = "<select></select>";
		document.getElementById("profs").innerHTML = "<select></select>";
		return
	}

var xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
{
	 alert ("Este browser não suporta HTTP Request")
	 return
}

var url=url;
url=url+"?id="+id;url=url+"?"+txt;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=function()
{
	 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 {
		 document.getElementById(container).innerHTML=xmlHttp.responseText;
	 }
}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function GetXmlHttpObject()
{
var objXMLHttp=null

	 if (window.XMLHttpRequest)
		 objXMLHttp=new XMLHttpRequest()
	 else if (window.ActiveXObject)
		 objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")

return objXMLHttp
}

Mas o meu this.txt está levando um valor undefined, por que?

 

Desde já agradeço

 

Marcelo

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pessoal,

 

coloquei esse comando

 

var indice = document.form1.cidades.selectedIndex

var txt=document.form1.cidades.options[indice].text

 

e pegou o valor do pais, no select, mas não quero o valor do selecte paises, quero o valor do select estado e / ou cidades, como faço?

 

Pois coloquei esse codigo acima na função e dava: é nulo ou não é um objeto, pois só funciona se eu colocar o select pais: document.form1.paises.selectedIndex

 

E agora?

 

<form method="POST" action="resultado.asp" name="form1">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
  <tr>
	<td width="100%"><font color="#3A5278" face="Arial Narrow" size="2">Países:</font></td>
  </tr>
  <tr>
	<td width="100%">
	<select name="paises" id="paises" onchange="RetornoAjax(this.value, 'estados.asp', 'estados')" style="font-family: Verdana; font-size: 10 px; color: #808080; border: 1px solid #808080">
<option value="">-Selecione-</option>
<% while not tab.eof %>
<option value="<%= tab("id_pais")%>"><%= tab("pais")%></option>
<% tab.movenext
	 wend
%>
</select></td>
  </tr>
  <tr>
	<td width="100%"><font color="#3A5278" face="Arial Narrow" size="2">Estados:</font></td>
  </tr>
  <tr>
	<td width="100%"><div name="estados" id="estados"><select style="font-family: Verdana; font-size: 10 px; color: #808080; border: 1px solid #808080"></select></div></td>
  </tr>
  <tr>
	<td width="100%"><font color="#3A5278" face="Arial Narrow" size="2">Cidades:</font></td>
  </tr>
  <tr>
	<td width="100%"><div name="cidades" id="cidades"><select style="font-family: Verdana; font-size: 10 px; color: #808080; border: 1px solid #808080"></select></div></td>
  </tr>
   <tr>
	<td width="100%"><font color="#3A5278" face="Arial Narrow" size="2">Zona 
	(Cidade de São Paulo):</font></td>
  </tr>

   <tr>
	<td width="100%"><div name="zona" id="zona"><select style="font-family: Verdana; font-size: 10 px; color: #808080; border: 1px solid #808080"></select></div></td>
  </tr>

  <tr>
	<td width="100%"><font color="#3A5278" face="Arial Narrow" size="2">Profissionais:</font></td>
  </tr>
  <tr>
	<td width="100%"><div name="profs" id="profs"><select style="font-family: Verdana; font-size: 10 px; color: #808080; border: 1px solid #808080"></select></div></td>
  </tr>
  <tr>
	<td width="100%">
	<input type="submit" value="Buscar" name="B1" style="color: #FFFFFF; font-size: 10 px; font-family: Verdana; border: 1px solid #808080; background-color: #3A5278"></td>
  </tr>
</table>

</form>
</td>
  </tr>
</table>

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.