Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help using Javascript and Forms

    Hello to you all, not gonna say as much as i said in the other forums i am registered on..i will just say i'm kind'off a starter here.
    I am portuguese, so my codes are usually displayed in portuguese (the variables, obvious))
    Anyways, i was creating a formulary to help some friends of mine with a class newspaper. I just wanted to have a parameter and code on wich you could show me how to save the user information (Tiped in the form) and create a new document that has it.
    So i wanted to know how to, without using 'mailtos', saving in the database or in the folder (if out of the web).

    I will pste the code of the File i have, you can also comment it if you want, but you don't have to. It's very simple, and easy to understand, i just want 'the' code:

    Code:
    <html>
    <head>
    <script type="text/javascript">
    </script>
    <style type="text/css">
    .borda {
    border: medium outset blue;
    font-size: large;
    text-align: justify;
    url ("http://img108.imageshack.us/img108/227/style2yb.jpg");
    no repeat fixed;
    center center
    }
    </style>
    <style type="text/css">
    .bordai {
    border: medium outset blue;
    font-size: large;
    text-align: justify;
    background-color=skyblue;
    }
    .borda2 {
    border: medium outset skyblue;
    
    font-size: large;
    text-align: justify;
    background-color=royalblue;
    }
    .topoesquerda {
    border: medium outset blue;
    font-size: large;
    text-align: justify;
    background-color=skyblue;
    position:absolute;
    left:500px;
    right:28px;
    top:146px;
    }
    a:link {color: #000033; text-decoration: none; font-weight: bold;}
    a:visited {color: #000033; text-decoration: none; font-weight: bold;}
    a:hover {color: royalblue; text-decoration: none}
    
    .bot {
    position:absolute;
    left:15px;
    right:300px;
    top:727px;
    }
    .esconder {
    visibility:hidden;
    position:absolute;
    left:500px;
    right:28px;
    top:146px;
    }
    </style>
    
    
    
    <script type="text/javascript">
    function valida() {
    var mensagem="";
    
    if (document.registo.Mail.value.indexOf("@") == -1) {
    mensagem=mensagem + "Endereço de correio errado, por favor insira um endereço correcto. \n\n";
    }
    if (document.registo.Nome.value.length < 1 || document.registo.Nome.value.length == 0)  {
    mensagem=mensagem + "Por favor insira um nome. \n\n";
    }
    if (document.registo.N.value.length > 35 || document.registo.N.value.length < 1)  {
    mensagem=mensagem + "O Nº deve estar contido entre 1 e 35. \n\n";
    }
    if (isNaN(document.registo.N.value))  {
    mensagem=mensagem + "O Nº deve ser apenas constituído por números. \n\n";
    }
    if (document.registo.Turma.value.length < 1 || document.registo.Turma.value.length > 3)  {
    mensagem=mensagem + "A Turma deve ter apenas três caractéres (ex: 1ºA). \n\n";
    }
    if (document.registo.Idade.value < 18 || document.registo.Idade.value > 70)  {
    mensagem=mensagem + "Deve ter pelo menos 18 anos para trabalhar no jornal e 70 no máximo. \n\n";
    }
    if (document.registo.Idade.value > 70 && document.registo.Cargo.value == "1")  {
    mensagem=mensagem + "Com essa idade, não pode ter um cargo tão elevado. \n\n";
    }
    if (document.registo.Idade.value > 70 && document.registo.Cargo.value == "2")  {
    mensagem=mensagem + "Com essa idade, não pode ter um cargo tão elevado. \n\n";
    }
    if (document.registo.Idade.value > 70 && document.registo.Cargo.value == "3")  {
    mensagem=mensagem + "Com essa idade, não pode ter um cargo tão elevado. \n\n";
    }
    if (document.registo.Idade.value > 70 && document.registo.Cargo.value == "4")  {
    mensagem=mensagem + "Com essa idade, não pode ter um cargo tão elevado. \n\n";
    }
    if (mensagem.length > 0) {
    alert (mensagem);
    }
    else {
    document.registo.submit()
    }
    }
    </script>
    </head>
    <body onload="document.registo.nome.focus();" background="http://img108.imageshack.us/img108/227/style2yb.jpg" no-repeat>
    <p class="topoesquerda">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;O sistema deste formulário é feito em <a href="http://www.google.com.br/search?hl=pt-BR&lr=&defl=pt&q=define:JavaScript&sa=X&oi=glossary_definition&ct=title" target="_blank">Javascript</a>, com um toque visual de<a href="http://www.google.com.br/search?hl=pt-BR&q=define%3ACSS&btnG=Pesquisar&meta=" target="_blank"> CSS</a>.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deverá preencher os campos correctamente e, se algum incoveniente ocorrer, o formulário será enviado para trás, informando os erros que ocorreram.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;O sistema funciona bem nos <a href="http://www.google.pt/search?hl=pt-BR&q=define%3A+browser&btnG=Pesquisa+Google" target="_blank">browsers</a> Internet Explorer e Mozilla Firefox, tendo alguns problemas no Opera e Netscape.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;O site funciona com a função <a href="http://www.google.com.br/search?hl=pt-BR&q=define%3Amailto&btnG=Pesquisar&meta=" target="_blank">MailTo</a> dentro do formulário.
    </p>
    <form enctype="text/plain" method="POST" name="registo" onsubmit="return valida();" action="mailto:jorl17@hotmail.com?subject=Registo">
    <textarea name="att" rows="10" cols="35" class="esconder">
    ----Copyright de sistema, totalmente reservado a Jorl17.----<br>Tentar enganar o sistema resultará em exclusão permanente da lista de candidatos e poderá levar ainda a ban do IP permanente do site.<br>
    Abaixo está o contéudo a ser enviado, não alterar ou será rejeitado, o código escondido detecta alterações, ou não.</textarea>
    <p class="borda"><span class="bordai">
    Nome:</span>&nbsp;&nbsp;
    <input type="text" name="Nome" size="20" maxlenght="30">
    <br><br><br><span class="borda2">
    Nº:</span>&nbsp;&nbsp;
    <input type="text" name="N" size="8" maxlenght="8">
    <br><br><br><span class="bordai">
    Turma:</span>&nbsp;&nbsp;
    <input type="text" name="Turma" size="8" maxlenght="8">
    <br><br><br></span><span class="borda2">
    Cargo a ter:
    </span>&nbsp;&nbsp;<select name="Cargo">
      <option value="1">Administrador do Jornal/Fundador</option>@
      <option value="2">Editor</option>
      <option value="3">Repórter</option>
      <option value="4">Jornalista</option>
      <option value="5">'Infiltrado'</option>
    </select>
    </span>
    <br><br><br></span><span class="bordai">
    Idade:</span>&nbsp;&nbsp;<input type="text" name="Idade" maxlenght="2">
    <br><br><br><span class="borda2">
    Mais algumas razões para seres escolhido:</span>
     <br><br><textarea bgcolor="#FF0000" name="Escolhido por" rows="10" cols="35" wrap="virtual">
    </textarea>
    
    <br><br><br><span class="bordai">
    Mail:</span>&nbsp;&nbsp;<input type="text" name="Mail" maxlenght="20">
    <br><br><br><br>
    </p><a class="bot" href=javascript:valida();> <img src="http://img108.imageshack.us/img108/1783/enviar5ru.jpg"></a>
    <br>
    </form>
    <br>
    </body>
    </html>
    It probably has unecessary things, but don't bother that
    Last edited by jorl17; 05-24-2006 at 09:06 PM.

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 513 Times in 500 Posts
    If you are saying serverside is not an option, are cookies an option?
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If they create a file with the desired information, yes. But if they just register the information and keep it, no.

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 513 Times in 500 Posts
    a cookie can hold 4k of data on the clients machine
    this data can be retrieved by a document in the same domin of the document that created the cookie and used to meet the requirement.

    This requirement may be to complete existing element values or to create elements using the DOM to display values stored in the cookie
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #5
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, i know all that...
    first of all, i wanted a code.
    Second, i wanted to directly create the file, i saw something like this at the Psswords security topic, one of the firsts in the 'post a javascipt'...

  • #6
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 513 Times in 500 Posts
    Yes, i know all that.
    well why ask dam fool questions?

    and get some manners before you return
    Last edited by vwphillips; 05-25-2006 at 09:08 AM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #7
    New to the CF scene
    Join Date
    May 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh wait, i read it all again, what I wanted is just that cookie, but i wanted it to be created in a specified folder...and in a special tipe of doocument, but, a js or vbs would be great...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •