Difference: JavaScript (3 vs. 4)

Revision 408 Oct 2010 - FlavioAraujo

Line: 1 to 1
 
%STARTINCLUDE%
<script type="text/javascript" src="%ATTACHURL%/jquery.js"></script>
<script type="text/javascript">
$("document").ready(function(){
Added:
>
>
var opcoes = [0,0,0,0,0]; var cont = 1;

function seleciona (it) { if (opcoes[it] == 0) { opcoes[it] = cont; } else { opcoes[it] = 0; } cont = 1;

for (var i = 0; i < 5; i++) { if (opcoes[i] = 0) cont++; }

for (var i = 1; i <= cont; i++) { //pra cada uma das opções selecionadas var menor = 5;

for (var j = 0; j < 5; j++) { //encontra a menor if (opcoes[j] >= i) { if ((menor == 5) || (opcoes[j] < opcoes[menor])) { menor = j; } } }

opcoes[menor] = i; }

for (var i = 0; i < 5; i++) { $(".mostrador:eq("+ i +")").html(opcoes[i]); } }

$("#inscricao :checkbox").click(function(){ if ($(this).attr("id") == "o1") { seleciona(0); } else if ($(this).attr("id") == "o2") { seleciona(1); } else if ($(this).attr("id") == "o3") { seleciona(2); } else if ($(this).attr("id") == "o4") { seleciona(3); } else if ($(this).attr("id") == "o5") { seleciona(4); } /*var of = $(this).attr("id"); $("#inscricao #oficinas").attr("value", $("#inscricao #oficinas").attr("value") + of );*/ });

  //preenchimento do formulario $("#inscricao :submit").click(function(){
Added:
>
>
var ordemOficinas = "\n"; for (var i = 1; i <= 5; i++) { ordemOficinas += "\n" + "Oficina " + i + ": " + opcoes[i-1]; }
  $("#inscricao textarea").attr("value",
"Nome
" + $("#inscricao #nome").attr("value") + "\n" +
"E-mail
" + $("#inscricao #from").attr("value") + "\n" +
Line: 15 to 72
  "Instituto e curso de origem: " + $("#inscricao #instituto").attr("value") + "\n" +
"Formação
" + $("#inscricao #formacao").attr("value") + "\n" +
"Observações
" + $("#inscricao #observacoes").attr("value") + "\n" +
Changed:
<
<
"Oficinas
" + $("#inscricao #oficinas").attr("value") + "\n"
>
>
"Oficinas
" + ordemOficinas + "\n"
  ); });
Deleted:
<
<
$("#inscricao :checkbox").click(function(){ var of = $(this).attr("id"); $("#inscricao #oficinas").attr("value", $("#inscricao #oficinas").attr("value") + of ); });
  $("#conteudo [href*='http://']").attr("target", "_blank"); $("#conteudo [href*='https://']").attr("target", "_blank");
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback