Ir para conteúdo
Fórum Script Brasil

Ronaldo Fernandes

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre Ronaldo Fernandes

Ronaldo Fernandes's Achievements

0

Reputação

  1. Prezados, Boa tarde, estou com dificuldade em um código ajax. Eu escrevi este código com o proposito de substituir espaços por underline e onde houver acentos remover os acento. Porém este código não está funcionando como eu esperava. Quando eu coloco a função para substituir espaços por underline a remoção dos acentos não funciona e vice versa e se as duas funções ficam ativas (Não comentada) o código não faz nada, ou seja o texto digitado fica com acentos e os espaços não é substituído. Por favor me ajudem. Segue o código para darem uma olhada. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=--=-=-==---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--==-=-=-=-=-=-=-= var p = 0; var vetorVideos; var t; var funcao; function getRequest() { request=false; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } return (request); } //pegando os dados e colocando no div function preenche_div () { p = 0; clearInterval(funcao); var request=getRequest(); var div = document.getElementById('quadro_videos'); //div que vai ser preenchido var campo = 'var='+document.getElementById('campo').value; //textarea que vai preencher o div if (request) { request.onreadystatechange = function () { if (request.readyState == 4 && request.status == 200) { div.innerHTML=""; var strVideos = request.responseText; vetorVideos = strVideos.split("|"); execVideos(); funcao = setInterval(execVideos,2000); } else { div.innerHTML="<img src=\"loading.gif\">"; } }; request.open("POST", "index_novo.php", true); request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.send(campo); } else { alert ("ERRO: Seu navegador não tem suporte a Ajax."); } } function execVideos() { if (vetorVideos.length>0) { document.getElementById('quadro_videos').innerHTML = "<video src='videos/videos/videos/"+vetorVideos[p++]+".ogv' type='video/ogg' width='387px' height='243px' autoplay></video>"; if (p == vetorVideos.length) { p = 0; } } } function retirarEspaco(objResp) { var varString = new String(objResp.value); var stringEspacos = new String(' '); var stringSemEspaco = new String('-'); var i = new Number(); var j = new Number(); var cString = new String(); var varRes = ''; for (i = 0; i < varString.length; i++) { cString = varString.substring(i, i + 1); for (j = 0; j < stringEspacos.length; j++) { if (stringAcentos.substring(j, j + 1) == cString){ cString = stringSemEspaco.substring(j, j + 1); } } varRes += cString; } objResp.value = varRes; } function retirarAcento(objResp) { var varString = new String(objResp.value); var stringAcentos = new String('àâêôûãõáéíóúçüÀÂÊÔÛÃÕÁÉÍÓÚÇÜ´`~^,.'); var stringSemAcento = new String('aaeouaoaeioucuAAEOUAOAEIOUCU'); var i = new Number(); var j = new Number(); var cString = new String(); var varRes = ''; for (i = 0; i < varString.length; i++) { cString = varString.substring(i, i + 1); for (j = 0; j < stringAcentos.length; j++) { if (stringAcentos.substring(j, j + 1) == cString){ cString = stringSemAcento.substring(j, j + 1); } } varRes += cString; } objResp.value = varRes; }
×
×
  • Criar Novo...