Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Fumo</title>
- <!-- jquery for equal height elements -->
- <script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
- <script type="text/javascript" src="js/formee.js"></script>
- <!-- css for structure -->
- <link rel="stylesheet" href="css/formee-structure.css" type="text/css" media="screen" />
- <!-- css for style -->
- <link rel="stylesheet" href="css/formee-style.css" type="text/css" media="screen" />
- <link rel="stylesheet" href="css/estilos.css" type="text/css" media="screen" />
- </head>
- <body>
- <div id="frm">
- <form class="formee" action="" method="post" id="formFumante">
- <fieldset>
- <legend>Perguntas</legend>
- <div class="grid-3-12">
- <label>Idade <em class="formee-req">*</em></label>
- <input type="text" name="idade" id="idade" class="formee-small" value="" />
- </div>
- <div class="clear"></div>
- <div class="grid-6-12">
- <label>Sexo <em class="formee-req">*</em></label>
- <ul class="formee-list">
- <li><input name="sexo" type="radio" value="M"/><label>Masculino</label></li>
- <li><input name="sexo" type="radio" value="F"/><label>Feminino</label></li>
- </ul>
- </div>
- <div class="clear"></div>
- <div class="grid-3-12">
- <label>Preço do maço de cigarro <em class="formee-req">*</em> R$</label>
- <input type="text" name="precocigarro" id="precocigarro" class="formee-small" value="3,50" />
- </div>
- <div class="clear"></div>
- <div class="grid-3-12">
- <label>Quantos maços fuma por dia ? <em class="formee-req">*</em></label>
- <input type="text" name="qtemacos" id="qtemacos" class="formee-small" value="" />
- </div>
- <div class="clear"></div>
- <div class="grid-3-12">
- <label>Há quantos anos você fuma ? <em class="formee-req">*</em></label>
- <input type="text" name="anosfumo" id="anosfumo" class="formee-small" value="" />
- </div>
- <div class="grid-12-12">
- <input type="submit" title="Calcular" value="Calcular" />
- </div>
- </fieldset>
- </form>
- </div>
- <div id="callBack">
- <h1>Respostas</h1>
- <div class="left">
- <p>Carga tabágica <strong id="ct"></strong> maços.ano</p>
- <p>Você gasta:</p>
- <p>Por mês: <strong id="gastomes"></strong></p>
- <p>Por Ano: <strong id="gastoano"></strong></p>
- <p>Você já gastou o total de: <strong id="gastototal"></strong></p>
- </div>
- <div class="left"> <p>Quantidade de cigarros que você já fumou:</p>
- <p>Por mês: <strong id="qcfmes"></strong> cigarros</p>
- <p>Por Ano: <strong id="qcfano"></strong> cigarros</p>
- <p>Durante toda sua vida: <strong id="qcfvida"></strong> cigarros</p>
- </div>
- <div class="clear"></div>
- <p>Se tivesse aplicado na poupança, você teria: <strong id="poupanca"></strong></p>
- <p>Se tivesse aplicado com rendimentos de 1% ao mês, você teria: <strong id="rendimento"></strong></p>
- <p>Altair da Silva Costa Jr. - cirurgiatoracica@uol.com.br</p>
- <span class="btnOk">
- <a href="javascript:;" title="Novo Calculo" class="formee-button ok">Novo Calculo</a>
- </span>
- </div>
- <script type="text/javascript" src="js/accounting.min.js"></script>
- <script type="text/javascript">
- $("#callBack").hide();
- function addCommas(nStr) {
- nStr += '';
- var x = nStr.split(',');
- var x1 = x[0];
- var x2 = x.length > 1 ? '.' + x[1] : '';
- var rgx = /(d+)(d{3})/;
- while (rgx.test(x1)) {
- x1 = x1.replace(rgx, '$1' + ',' + '$2');
- }
- return x1 + x2;
- }
- $(function (){
- $("#formFumante").submit(function (){
- var msg = "";
- var teste = false;
- var cargatabagica=$("input[id='qtemacos']").val()*$("input[id='anosfumo']").val();
- var gastomes = $("input[id='qtemacos']").val()*30*addCommas($("input[id='precocigarro']").val());
- var gastoano = gastomes*12;
- var gastototal = gastoano*$("input[id='anosfumo']").val();
- var qcfmes = ($("input[id='qtemacos']").val()*20)*30;
- var qcfano = qcfmes*12;
- var qcfvida = qcfano*$("input[id='anosfumo']").val();
- var poupanca = gastomes * (Math.pow((1 + 0.0065),$("input[id='anosfumo']").val()*12)-1)/0.0065 ;
- var rendimento = gastomes * (Math.pow((1 + 0.01),$("input[id='anosfumo']").val()*12)-1)/0.01;
- $('#ct').html(cargatabagica);
- $('#gastomes').html('R$ '+accounting.formatMoney(gastomes,""));
- $('#gastoano').html('R$ '+accounting.formatMoney(gastoano,""));
- $('#gastototal').html('R$ '+accounting.formatMoney(gastototal,""));
- $('#qcfmes').html(accounting.formatMoney(qcfmes,"", ".", "."));
- $('#qcfano').html(accounting.formatMoney(qcfano,"", ".", "."));
- $('#qcfvida').html(accounting.formatMoney(qcfvida,"", ".", "."));
- $('#poupanca').html(accounting.formatMoney(poupanca,"R$ "));
- $('#rendimento').html(accounting.formatMoney(rendimento,"R$ "));
- if ($("input[id='idade']").val() == "") {
- teste = true;
- };
- if ($("input[id='precocigarro']").val() == "") {
- teste = true;
- };
- if ($("input[id='sexo']").val() == "") {
- teste = true;
- };
- if ($("input[id='qtemacos']").val() == "") {
- teste = true;
- };
- if ($("input[id='anosfumo']").val() == "") {
- teste = true;
- };
- if (teste) {
- msg = "Todas as perguntas devem ser respondidas!";
- }
- if (msg){
- alert(msg);
- //return false;
- } else {
- $("#frm").hide();
- $("#callBack").fadeIn();
- //document.formFumante.reset();
- }
- return false;
- });
- $(".ok").click(function(){
- document.forms[0].reset();
- $("#callBack").hide();
- $("#frm").fadeIn();
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement