Your SlideShare is downloading. ×
Exemplos Aula2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Exemplos Aula2

570

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
570
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
44
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. D:DocumentosSofteamCoordCursosPHPMYSQLEXEMPLOS_AULA2.PHP terça-feira, 3 de fevereiro de 2009 17:09 EXEMPLO 1 <html> <head> <title> Primeiro Java Script</title> <script language=quot;JavaScriptquot;> <!-- function iniciando() { alert(quot;Seu nome é quot;+document.form.nome.value); } --> </script> </head> <body> <form action=quot;Exemplo1.phpquot; method=quot;postquot; name=quot;formquot; onSubmit=quot;iniciando()quot;> Nome: <Input type=quot;textquot; name=quot;nomequot; /> <Input type=quot;submitquot; name=quot;submitquot; value=quot;Confirmequot; /> </form> </body> </html> EXEMPLO 2 <html> <head> <title> Primeiro Java Script</title> <script language=quot;JavaScriptquot;> <!-- Curso = quot;Programação para Webquot;; function iniciando() { alert (quot;Seu nome é quot;+document.form.nome.value +quot; do curso quot;+Curso); } --> </script> </head> <body> -1-
  • 2. D:DocumentosSofteamCoordCursosPHPMYSQLEXEMPLOS_AULA2.PHP terça-feira, 3 de fevereiro de 2009 17:09 <form action=quot;Exemplo1.phpquot; method=quot;postquot; name=quot;formquot; onSubmit=quot;iniciando()quot;> Nome: <Input type=quot;textquot; name=quot;nomequot; /> <Input type=quot;submitquot; name=quot;submitquot; value=quot;Confirmequot; /> </form> </body> </html> EXEMPLO 3 <html> <head> <title> Primeiro Java Script</title> <script language=quot;JavaScriptquot;> <!-- //Curso = quot;Programação para Webquot;; function isDigit (c){ if ((c<='9') && (c>='0')) return true; else return false; } function isHifen (c,j){ if ((j=='4') && (c=='-')) return true; else return false; } function validarTelefone(){ var telefone = document.form.telefone.value; for (i = 0; i<9; i++){ if ((!isDigit(telefone.charAt(i))) && (!isHifen(telefone.charAt(i),i))){ alert (quot;Este campo só aceita números e precisa ter o formato xxxx-xxxxquot;); document.form.telefone.focus(); return true; } } return false; } function iniciando() { if (!validarTelefone()) { alert (quot;Seu nome é quot;+document.form.nome.value +quot; do curso quot;+Curso); document.form.submit(); } } -2-
  • 3. D:DocumentosSofteamCoordCursosPHPMYSQLEXEMPLOS_AULA2.PHP terça-feira, 3 de fevereiro de 2009 17:09 --> </script> </head> <body> <form action=quot;Exemplo3.phpquot; method=quot;postquot; name=quot;formquot; > Nome: <Input type=quot;textquot; name=quot;nomequot; /> Telefone: <input type=quot;textquot; name=quot;telefonequot; si size=quot;9quot; /> </form><br> <a href=quot;javascript:iniciando()quot; > Salvar </a> </body> </html> EXEMPLO 4 <html> <head> <title> Primeiro Java Script</title> <script language=quot;JavaScriptquot;> <!-- Curso = quot;Programação para Webquot;; function validarCampos() { var nome = document.form.nome.value; var telefone = document.form.telefone.value; var email = document.form.email.value; if ((ehNull(nome)) || (ehNull(email)) || (ehNull(telefone))){ alert(quot;Um dos campos solicitados se encontra vazioquot;); document.form.nome.focus(); return true; } return false; //document.form.submit(); } function iniciando(){ if (!validarCampos()) { alert (quot;Seu nome é quot;+document.form.nome.value +quot; do curso quot;+Curso); document.form.submit(); } } function ehNull (a){ if (a==quot;quot;) return true; else return false; -3-
  • 4. D:DocumentosSofteamCoordCursosPHPMYSQLEXEMPLOS_AULA2.PHP terça-feira, 3 de fevereiro de 2009 17:09 } --> </script> </head> <body> <form action=quot;Exemplo3.phpquot; method=quot;getquot; name=quot;formquot; > Nome: <Input type=quot;textquot; name=quot;nomequot; /> Email: <input type=quot;textquot; name = quot;emailquot; /> Telefone: <input type=quot;textquot; name=quot;telefonequot; size=quot;9quot; /> </form><br> <a href=quot;javascript:iniciando()quot; > Salvar </a> </body> </html> EXEMPLO 5 <html> <head> <title> Primeiro Java Script</title> <script language=quot;JavaScriptquot;> <!-- function AbreJanela() { if (document.Form1.Opcao[0].checked) {escolha = 1} else {escolha = 2}; NovaJanela = window.open(quot;quot;, quot;OutraJanelaquot;, quot;width=300,height=400quot;); NovaJanela.document.open(); NovaJanela.document.write(quot;<html><head><title>Nova Janelaquot;); NovaJanela.document.write(quot;</title></head><body bgcolor='white'>quot;); if (escolha == 1) { NovaJanela.document.write(quot;<hr><h1 align=center>Logomarca Elogica</h1><hr>quot; );} else { NovaJanela.document.write (quot;<hr><h1 align=center>Recife Alto Astral</h1><hr>quot;);} NovaJanela.document.write (quot;<form><input type='button' value='Fecha Janela' onClick='window.close()'>quot;); NovaJanela.document.write (quot;</form></body></html>quot;); NovaJanela.document.close(); } --> </script> -4-
  • 5. D:DocumentosSofteamCoordCursosPHPMYSQLEXEMPLOS_AULA2.PHP terça-feira, 3 de fevereiro de 2009 17:09 </head> <body> <p></p> <p>Escolha a frase a ser apresentada na nova janela:</p> <form method=quot;POSTquot; name=quot;Form1quot;> <p> <input type=quot;radioquot; name=quot;Opcaoquot; value=quot;1quot; checked>Elogica <input type=quot;radioquot; name=quot;Opcaoquot; value=quot;2quot;>Recife </p> <p> <input type=quot;buttonquot; name=quot;Enviaquot; value=quot;Nova Janelaquot; onClick=quot;AbreJanela()quot;> </p> </form> </body> </html> EXEMPLO 6 <html> <head> <title> Primeiro Java Script</title> <script language=quot;JavaScriptquot;> <!-- Curso = quot;Programação para Webquot;; function isDigit (c){ if ((c<='9') && (c>='0')) return true; else return false; } function isHifen (c,j){ if ((j=='4') && (c=='-')) return true; else return false; } function formatar(src, mask){ var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i) if (texto.substring(0,1) != saida) { src.value += texto.substring(0,1); } } -5-
  • 6. D:DocumentosSofteamCoordCursosPHPMYSQLEXEMPLOS_AULA2.PHP terça-feira, 3 de fevereiro de 2009 17:09 --> </script> </head> <body> <form action=quot;Exemplo3.phpquot; method=quot;postquot; name=quot;formquot; > Nome: <Input type=quot;textquot; name=quot;nomequot; /> Telefone: <input type=quot;textquot; name=quot;telefonequot; maxlenght=quot;9quot; onKeyPress= quot;formatar(this,'####-####')quot; /> </form><br> <a href=quot;javascript:iniciando()quot; > Salvar </a> </body> </html> -6-

×