Jump to content
Fórum Script Brasil
  • 0




Boas, alguém ajudar a criar script de verificar checkbox e radio e o value das opçoes do checkbock e radio é escrito para ficheiro txt.


<DOCTYPE html>
<title>  frequencia1 </title>
<link rel="stylesheet" type="text/css"  href="./frequencia1.css"  />
<h2>Ficha de Encomenda de Pizzas</h2>

<p>Qual a Pizza a encomendar? 
 <select name="pizza1" id="pizza">
   <option value="" selected disabled hidden></option>
   <option value="Fiambre com cogumelos">Fiambre com cogumelos</option>
   <option value="Bacon com fiambre">Bacon com fiambre</option>
   <option value="Queijo com cogumelos">Queijo com cogumelos</option>
 <select name="quantidade11" id="quantidade1">
   <option value="" selected disabled hidden>0</option>
   <option value="1">1</option>
   <option value="2">2</option>
   <option value="3">3</option>
   <option value="4">4</option>

Qual a bebida?
<select name="bebida1" id="bebida">
   <option value="" selected disabled hidden></option>
   <option value="CocaCola">CocaCola</option>
   <option value="Ice Tea Limão">Ice Tea Limão</option>
   <option value="Fanta Laranja">Fanta Laranja</option>
<select name="quantidade22" id="quantidade2">
   <option value="" selected disabled hidden>0</option>
   <option value="1">1</option>
   <option value="2">2</option>
   <option value="3">3</option>
   <option value="4">4</option>

<form name="opcoes1" id="opcoes">
<input type="checkbox" id="opcao" name="opcao" value="Extra Queijo"> Extra Queijo
<input type="checkbox" id="opcao" name="opcao" value="Massa Grossa"> Massa Grossa
<input type="checkbox" id="opcao" name="opcao" value="Pimentos"> Pimentos
<input type="checkbox" id="opcao" name="opcao" value="Cogumelos"> Cogumelos


<p><b>Dados para <br> entrega</b></p>
<p> Nome: 
<input type="text" name="nome1" id="nome" size="50" value="">
<input type="text" name="morada1" id="morada" size="40" value=""> </p>
<p> Telefone: 
<input type="text" name="telefone1" id="telefone" value=""> </p>


<p><b> Forma de pagamento </b></p>
<form name="pagamento11" id ="pagamento">
<input type="radio" id="pagamento1" value="VISA"> VISA
<input type="radio" id="pagamento2" value="Contra Entrega"> Contra Entrega 
<input type="radio" id="pagamento3" value="Factura"> Factura(30 dias, +15%)<br>
<p>Número do cartão VISA
<input type="text" name="visa11" id="visa1" size="20" value=""> </p>


<button onclick="saveTextAsFile()" id="inputFileNameToSaveAs">Enviar!</button>
<button onclick="limpa1" >Limpar</button>

function saveTextAsFile(){
            var textToWrite = document.getElementById("pizza").value + " " + document.getElementById("quantidade1").value + "\n" +
            document.getElementById("bebida").value + " " + document.getElementById("quantidade2").value + "\n" +
            document.getElementById("opcoes").value + "\n" + 
            document.getElementById("nome").value + "\n" + 
            document.getElementById("morada").value + "\n" + 
            document.getElementById("telefone").value + "\n" + 
            document.getSelection("radio").value + "\n" + 
            var textFileAsBlob = new Blob([textToWrite],{type:'text/plain'});
            var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value;
            var downloadLink = document.createElement("a");
            downloadLink.download = fileNameToSaveAs;
            downloadLink.innerHTML = "Dowmload File";
            if(window.webkitURL !=null){downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);}

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.

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
    • Total Posts
  • Create New...