Jump to content
Fórum Script Brasil
  • 0

JS funciona no IE, mas não no Chrome nem no FF


ViaPocket

Question

To tentando realizar a seguinte "façanha".

Popular um combo via ajax.

A página server (em ASP) faz isso:

<%
Dim varId, ParametrosSQL, varCodProp
'Recupera dados da Session------------------------------------------------------------------------
ParametrosSQL=Split(Session("autentica"),";")
varCodProp=ParametrosSQL(1) 
varCodAutor=ParametrosSQL(0) 
varId=Request.Form("Id")
sql= "SELECT TurmasCod, TurmasCodCliente, TurmasTitulo, TurmasCodControle, TurmasCodCurso, TurmasSt, TurmasLotacao, TurmasUCad FROM TURMAS WHERE TurmasCodCurso = '"&varId&"' AND TurmasCodCliente = '"&varCodProp&"' AND TurmasUCad= '"&varCodAutor&"'"
Set rs= MM_conexao_STRING.Execute(sql)
response.write("Selecione..."&";")
if not rs.eof then
 while not rs.eof
  response.write(rs("TurmasCod")&";") 
  response.write(rs("TurmasTitulo")&";")
 rs.movenext()
 wend
end if
set rs=nothing
%>
Funciona o código acima. Mas o código abaixo deveria pegar a string retornada do AJAX e popular um combo. O galho é que quando submeto a pg aparece "undefined"
&lt;script>
function populaTurmas()
{
docto=document.frmEvento;
varId = docto.hiddenCodCurso.value;

var objTurmas = createXMLHTTP(); 
objTurmas.open("post", "Backend/select/turmas.asp", true); 
objTurmas.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

objTurmas.onreadystatechange=function(){
if (objTurmas.readyState==3){
document.getElementById("ajaxLoadTurmas").style.display = "inline"; 
}
else
campo_select = document.getElementById("txtTurmas");

if (objTurmas.readyState==4){ 
    document.getElementById("txtTurmas").disabled = 0;

**************acho que o problema está daqui em diante*************************

    campo_select.options.length = 0;
    results = objTurmas.responseText.split(";");
    for( i = 0; i < results.length; i++ )
    { 
      string = results[i].split( ";" );
      campo_select.options[i] = new Option( string[0], string[1] );

    //Linha abaixo não funciona
     // campo_select.value[i]= new Option( string[0], string[1] );
          
    }
}}
objTurmas.send("Id="+ varId);
}
</script>

Birgado!

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...