Ir para conteúdo
Fórum Script Brasil

Jonathan Queiroz

Membros
  • Total de itens

    3.718
  • Registro em

  • Última visita

Tudo que Jonathan Queiroz postou

  1. O que você já fez até agora ?
  2. Se você digitar "Joao Vitor" a função scanf irá recuperar o valor como foi escrito (com todos os espaços) Se desejar concatenar duas strings, busque por strcat da string.h
  3. Tópico duplicado: http://scriptbrasil.com.br/forum/index.php?showtopic=138188 O tópico será fechado e as respostas deverão ser postadas no outro tópico.
  4. O código acima funciona Onde está sua dúvida ?
  5. Achei o erro. É porque eu procurava uma string em um intervalo pré-definido do valor do textarea (textarea.value), mas esse intervalo era referente à variável valor_inicial, que armazenada o valor do textarea antes de ser modificado. O código está assim: function getSelection(inputBox) { if ("selectionStart" in inputBox) { return { start: inputBox.selectionStart, end: inputBox.selectionEnd } } //and now, the blinkered IE way var bookmark = document.selection.createRange().getBookmark() var selection = inputBox.createTextRange() selection.moveToBookmark(bookmark) var before = inputBox.createTextRange() before.collapse(true) before.setEndPoint("EndToStart", selection) var beforeLength = before.text.length var selLength = selection.text.length return { start: beforeLength, end: beforeLength + selLength } } function InsereCodigo(valor,tag_fechamento,tipo,minvalue,maxvalue){ var ie=navigator.appName.indexOf("Internet Explorer")>0 var textarea=document.getElementById("mensagem") var t=getSelection(textarea) var valor_inicial=textarea.value var soma=(ie?(t.start>1?2:0):0) t.start+=soma var tamanho_selecionado = t.end-t.start var inicio_selecao=t.start var fim_selecao=(tag_fechamento?t.end+soma:valor_inicial.length) var valor2="" if(tipo!=null){ valor2="=" var vn do{ vn=prompt(tipo) }while((minvalue && maxvalue) && (vn>maxvalue || vn<minvalue)) valor2+=vn } textarea.value="" textarea.value=valor_inicial.substring(0,inicio_selecao)+"["+valor+valor2+"]"+valor_inicial.substring(inicio_selecao,fim_selecao) if(tag_fechamento){ textarea.value+="[/"+valor+"]" textarea.value+=valor_inicial.substring(fim_selecao,valor_inicial.length) } //dá novamente o foco ao textarea textarea.focus() textarea.selectionStart=inicio_selecao+valor.length+valor2.length+2 textarea.selectionEnd=textarea.selectionStart+tamanho_selecionado } onload=function(){ //Negrito CreateTag("InsereNegrito","b",true) //Itálico CreateTag("InsereItalico","i",true) //Sublinhado CreateTag("InsereSublinhado","u",true) //Riscado CreateTag("InsereRiscado","s",true) //Overline CreateTag("InsereOverline","overline",true) //Sobrescrito CreateTag("InsereSobrescrito","sobrescrito",true) //Subscrito CreateTag("InsereSubscrito","subscrito",true) //Pré-formatação CreateTag("InserePre","pre",true) //Inserir imagem CreateTag("InsereImagem","img",false,"Digite uma imagem") //Inserir usuário CreateTag("InsereUser",true,"Digite o nome do usuário") //Inserir e-mail CreateTag("InsereMail",true,"Digite o e-mail") //Modificar tamanho CreateTag("InsereSize","size",true,"Tamanho da letra (1 a 7)",1,7) //Link's CreateTag("InsereURL","url",true,"Digite a página desejada") //Comentários CreateTag("InsereComentario","comment",true) //Lista CreateTag("InsereLista","list",true) //Marcador CreateTag("InsereMarcador","*",false) //Tabela CreateTag("InsereTabela","table",true) //Thead CreateTag("InsereTHead","thead",true) //Tbody CreateTag("InsereTBody","tbody",true) //Linha CreateTag("InsereLinha","tr",true) //Coluna CreateTag("InsereColuna","td",true) //Quote CreateTag("InsereQuote","quote",true) //Code CreateTag("InsereCode","code",true) //ASP CreateTag("InsereASP","asp",true) } function CreateTag(id,v1,v2,v3,v4,v5){ var el=document.getElementById(id) if(el){ el.onclick=function(){ InsereCodigo(v1,v2,v3,v4,v5) } } }[/codebox] Obs.: Padronizei um pouco o script com a função "CreateTag" É porque usarei esse script em mais de um fórum e algumas dessas funções serão desnecessárias num dos fóruns. O arquivo do BBCode (feito em ASP.NET VB) e o javascript serão o mesmo, deixando que o script seja utilizado, mas não é necessário inserir essa opção no painel de edição. Assim, se a função não encontrar o elemento não retornará nenhum erro ao navegador. Ao utilizar a função, o primeiro parâmetro é o id do elemento e os outros cinco serão repassados à função InsereCodigo Ainda não pude testar no IE6 e IE7 porque estou utilizando o Windows 7 e vem com o IE8. Estou instalando um programa (IETester) que permite testar aplicações desde o IE 5.5 até o IE8 Se funcionar, postarei no repositório de scripts
  6. Nesse caso basta utilizar o código referenciando os dois campos new dgCidadesEstados( document.getElementById('estado'), document.getElementById('cidade'), true ); new dgCidadesEstados( document.getElementById('estado1'), document.getElementById('cidade1'), true );
  7. Imaginei que você queria fazer uma verificação se o arquivo existe antes de redirecionar Nesse caso, movendo: ASP - Ajax,Javascript,XML,DOM Olhe isso: document.location.href="http://192.168.0.1/docs"document.formulario.arquivo.value + ".pdf" Tente assim: document.location.href="http://192.168.0.1/docs"+document.formulario.arquivo.value + ".pdf"
  8. Essa não é a área correta. Pedirei que movam para Classificados & Serviços
  9. Teste em outra página mais pesada, de forma que dê tempo de ver o carregamento. Tente também testar o gif puro em outra página e verificar seu tamanho.
  10. Isso aí só faz criar uma página na qual você digita o nome do arquivo e ele redireciona Se você quer digitar manualmente e verificar se o arquivo existe recomendo que busque por global.asa
  11. Salvar arquivos com Javascript seria algo bem complicado. Mas não impossível. Tente algo como isso: <html> <head> <script type="text/javascript"> onload=function(){ var arquivo="arquivo.txt" var fso=new ActiveXObject("Scripting.FileSystemObject") fso.OpenTextFile(arquivo,ForWriting) var valor_inicial=PegaValor(arquivo) alert("Valor inicial: \n"+valor_inicial) file.Write("Contagem "+(parseInt(valor_inicial.replace("Contagem ",""))+1)) file.WriteLine() } function PegaValor(arquivo){ var fso=new ActiveXObject("Scripting.FileSystemObject") var file=fso.OpenTextFile(arquivo,ForReading) return fs.read } </script> </head> <body> </body> </html> Mas seria um grande problema com navegadores. Só funcionaria no IE. Obs.: No IE8 não consegui abrir o arquivo para gravar (ForWriting), apenas para leitura (ForReading) Sendo assim, só testei a parte de leitura. Mas deve funcionar em outras versões
  12. Realmente...Gerar o link de forma aleatória no momento em que for clicado seria bem melhor
  13. Se estiver usando DDD o correto seria substring(3,5) O segundo parâmetro do método substring indica o caractere final da string e não quantos caracteres a função deve percorrer
  14. Dica: Ao invés de if/elseif/else, tente utilizar sempre que possível o switch caso as comparações tratem de uma mesma variável Por exemplo, o seguinte código: valor=5 if(valor==5){ alert("Cinco !") }elseif(valor==15){ alert("Vinte !") }else{ alert("Qualquer outro") } Poderia ser reduzido dessa forma: valor=5 switch(valor){ case 5: alert("Cinco !") break case 20: alert("Vinte !") break default: alert("Outro qualquer !") } Obs.: Java é diferente de Javascript
  15. Veja se esse link ajuda: http://www.macoratti.net/arq_ini.htm
  16. Consegui acertar o script aqui ! O código ficou assim: function getSelection(inputBox) { if ("selectionStart" in inputBox) { return { start: inputBox.selectionStart, end: inputBox.selectionEnd } } //and now, the blinkered IE way var bookmark = document.selection.createRange().getBookmark() var selection = inputBox.createTextRange() selection.moveToBookmark(bookmark) var before = inputBox.createTextRange() before.collapse(true) before.setEndPoint("EndToStart", selection) var beforeLength = before.text.length var selLength = selection.text.length return { start: beforeLength, end: beforeLength + selLength } } function InsereCodigo(valor,tag_fechamento,tipo,minvalue,maxvalue){ var ie=navigator.appName.indexOf("Internet Explorer")>0 var textarea=document.getElementById("mensagem") var t=getSelection(textarea) var valor_inicial=textarea.value var soma=(ie?(t.start>1?2:0):0) t.start+=soma var tamanho_selecionado = t.end-t.start var inicio_selecao=t.start var fim_selecao=(tag_fechamento?t.end+soma:valor_inicial.length) var valor2="" if(tipo!=null){ valor2="=" var vn do{ vn=prompt(tipo) }while((minvalue && maxvalue) && (vn>maxvalue || vn<minvalue)) valor2+=vn } textarea.value="" textarea.value=valor_inicial.substring(0,inicio_selecao)+"["+valor+valor2+"]"+valor_inicial.substring(inicio_selecao,fim_selecao) if(tag_fechamento){ textarea.value+="[/"+valor+"]" textarea.value+=valor_inicial.substring(fim_selecao,textarea.length) } //dá novamente o foco ao textarea textarea.focus() textarea.selectionStart=inicio_selecao+valor.length+valor2.length+2 textarea.selectionEnd=textarea.selectionStart+tamanho_selecionado } onload=function(){ //Negrito var btnNegrito=document.getElementById("InsereNegrito") btnNegrito.onclick=function(){ InsereCodigo("b",true) } //Itálico var btnItalico=document.getElementById("InsereItalico") btnItalico.onclick=function(){ InsereCodigo("i",true) } //Sublinhado var btnSublinhado=document.getElementById("InsereSublinhado") btnSublinhado.onclick=function(){ InsereCodigo("u",true) } //Riscado var btnRiscado=document.getElementById("InsereRiscado") btnRiscado.onclick=function(){ InsereCodigo("s",true) } //Overline var btnOverline=document.getElementById("InsereOverline") btnOverline.onclick=function(){ InsereCodigo("overline",true) } //Sobrescrito var btnSobrescrito=document.getElementById("InsereSobrescrito") btnSobrescrito.onclick=function(){ InsereCodigo("sobrescrito",true) } //Subscrito var btnSubscrito=document.getElementById("InsereSubscrito") btnSubscrito.onclick=function(){ InsereCodigo("subscrito",true) } //Pré-formatação var btnPre=document.getElementById("InserePre") btnPre.onclick=function(){ InsereCodigo("pre",true) } //Inserir imagem var btnImagem=document.getElementById("InsereImagem") btnImagem.onclick=function(){ InsereCodigo("img",false,"Digite uma imagem") } //Inserir usuário var btnUser=document.getElementById("InsereUser") btnUser.onclick=function(){ InsereCodigo("user",true,"Digite o nome do usuário") } //Inserir e-mail var btnMail=document.getElementById("InsereMail") btnMail.onclick=function(){ InsereCodigo("email",true,"Digite o e-mail") } //Modificar tamanho var btnSize=document.getElementById("InsereSize") btnSize.onclick=function(){ InsereCodigo("size",true,"Tamanho da letra (1 a 7)",1,7) } //Link's var btnUrl=document.getElementById("InsereUrl") btnUrl.onclick=function(){ InsereCodigo("url",true,"Digite a página desejada") } //Comentários var btnComentario=document.getElementById("InsereComentario") btnComentario.onclick=function(){ InsereCodigo("comment",true) } //Lista var btnLista=document.getElementById("InsereLista") btnLista.onclick=function(){ InsereCodigo("list",true) } //Marcador var btnMarcador=document.getElementById("InsereMarcador") btnMarcador.onclick=function(){ InsereCodigo("*",false) } //Tabela var btnTabela=document.getElementById("InsereTabela") btnTabela.onclick=function(){ InsereCodigo("table",true) } //Thead var btnTHead=document.getElementById("InsereTHead") btnTHead.onclick=function(){ InsereCodigo("thead",true) } //Tbody var btnTbody=document.getElementById("InsereTBody") btnTbody.onclick=function(){ InsereCodigo("tbody",true) } //Linha var btnLinha=document.getElementById("InsereLinha") btnLinha.onclick=function(){ InsereCodigo("tr",true) } //Coluna var btnColuna=document.getElementById("InsereColuna") btnColuna.onclick=function(){ InsereCodigo("td",true) } //Quote var btnQuote=document.getElementById("InsereQuote") btnQuote.onclick=function(){ InsereCodigo("quote",true) } //Code var btnCode=document.getElementById("InsereCode") btnCode.onclick=function(){ InsereCodigo("code",true) } //ASP var btnASP=document.getElementById("InsereASP") btnASP.onclick=function(){ InsereCodigo("asp",true) } } Obs.: Implementei algumas coisas no código. Agora é possível inserir tag's que solicitem um valor ao usuário (ficará após o sinal de "="), como a url, img, etc. Obs.: O primeiro parâmetro continua indicando a tag que deverá ser adcionada O segundo indica se a tag deverá ser fechada O terceiro indica o que o sistema irá perguntar ao usuário para inserir valores na tag (deixe em branco se a tag não necessita de valores)
  17. Sua dúvida está em como fazer a inclusão via servidor ou como fazer para o JavaScript enviar os dados para o servidor ?
  18. Nesse caso não haverá repetições dentro de uma mesma página, mas caso você atualize a página os valores poderão se repetir Quanto ao script do Jow, há sim possibilidade de se repetir em páginas diferentes. No entanto, isso é quase impossível (um em 10^12)
  19. Isso aí é com JavaScript Movendo: ASP --> Ajax, JavaScript, XML, DOM
  20. Você deve utilizar o método getSeconds da classe Date Mais informações: CriarWeb.com - Classe Date em Javascript
  21. Olhe isso aqui: ( x )End-A Caracteres como _ (underline) são permitidos, mas não é possível utilizar o - Quanto ao cálculo da área, você não atribuiu um valor à variável "pot" Obs.: O ** seria uma potência ? Aparentemente o resto está correto
  22. Jonathan Queiroz

    Funções

    Basta você fazer a chamada à normalmente dentro do bloco if
  23. Jonathan Queiroz

    Funções

    Seria isto ? #include<stdio.h> int soma(int n1,int n2); int main(){ int x=soma(5,15); printf("%i",x); for(;;); } int soma(int n1,int n2){ return n1+n2; }
  24. Tente postar o código completo dos formulários Aparentemente o javascript está certo !
×
×
  • Criar Novo...