Ir para conteúdo
Fórum Script Brasil
  • 0

Calculo final


Gabriel Gois

Pergunta

Fiz essas formulas em JP.

So consegui puxar o valor de um campo, no campo TOTAL.

Gostaria que cada escolha que fosse feita, no campo TOTAL aparecesse a soma de todas.

Meu codigo

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xml:lang="en-us" lang="en-us" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Enrolment Form - Latin America</title>
&lt;script language="javascript">
<!--
function calculaGeneral(valorSelecionado){
var objSpan = document.getElementById("SPAN_TOTAL");

if(valorSelecionado == "--Select--"){
objSpan.innerHTML = "$ 0.0";
return;
}

if(valorSelecionado >= 1 && valorSelecionado <= 15){
objSpan.innerHTML = "$" + (valorSelecionado * 230);
}else if(valorSelecionado >= 16 && valorSelecionado <= 23){
objSpan.innerHTML = "$" + (valorSelecionado * 220);
}else if(valorSelecionado >= 24 && valorSelecionado <= 52){
objSpan.innerHTML = "$" + (valorSelecionado * 210)
}

}

function calculaPreparation(valorSelecionado){
var objSpan = document.getElementById("SPAN_TOTAL");

if(valorSelecionado == "--Select--"){
objSpan.innerHTML = "$ 0.0";
return;
}
if(valorSelecionado =10){
objSpan.innerHTML = "$" + (valorSelecionado * 230);
}else if(valorSelecionado =12){
objSpan.innerHTML = "$" + (valorSelecionado * 230);
}
}
function calculaMaterial(valorSelecionado){
var objSpan = document.getElementById("SPAN_TOTAL");

if(valorSelecionado == "--Select--"){
objSpan.innerHTML = "$ 0.0";
return;
}
if(valorSelecionado >= 1 && valorSelecionado <= 4){
objSpan.innerHTML = "$" + (valorSelecionado * 60);
}else if(valorSelecionado >= 5 && valorSelecionado <= 8){
objSpan.innerHTML = "$" + (valorSelecionado * 90);
}else if(valorSelecionado >= 9 && valorSelecionado <= 12){
objSpan.innerHTML = "$" + (valorSelecionado * 120)
}else if(valorSelecionado >= 13 && valorSelecionado <= 24){
objSpan.innerHTML = "$" + (valorSelecionado * 150);
}else if(valorSelecionado >= 25 && valorSelecionado <= 52){
objSpan.innerHTML = "$" + (valorSelecionado * 180);
}

}

function calculaOSHC(valorSelecionado){
var objSpan = document.getElementById("SPAN_TOTAL");

if(valorSelecionado == "--Select--"){
objSpan.innerHTML = "$ 0.0";
return;
}

if(valorSelecionado >= 1 && valorSelecionado <= 52){
objSpan.innerHTML = "$" + (valorSelecionado * 35);
}

}
-->
</script>
</head>

<body>
<form action="envia_form.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<fieldset style="width:450px">


<table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
<tr bgcolor="#0E59AA">
<td colspan="2"><div align="center"><font size="4"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Brazil</font></strong></font></div></td>
</tr>
<tr>
<td width="144" bgcolor="#0691C1"><font color="#FFFFFF">First Name</font></font></td>
<td width="250"><label for="textfield"></label>
<input type="text" name="textfield" id="textfield" /></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Middle Name</font></font></td>
<td><label for="textfield2"></label>
<input type="text" name="textfield2" id="textfield2" /></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Last Name</font></font></td>
<td><label for="textfield3"></label>
<input type="text" name="textfield3" id="textfield3" /></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Date of Birth</font></font></td>
<td><label for="textfield4"></label>
<label for="select6"></label>
<label for="textfield4"></label>
<label>
<input type="text" name="textfield4" id="textfield4" />
</label>
<label for="select7"></label></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Gender</font></font></td>
<td><label for="select6"></label>
<select name="select6" id="select6">
<option>--Select--</option>
<option>Male</option>
<option>Female</option>
</select></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Email</font></font></td>
<td><label for="textfield5"></label>
<input type="text" name="textfield5" id="textfield5" /></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Your Visa Details</font></font></td>
<td><label for="select"></label>
<select name="select" id="select">
<option selected="selected">--Select--</option>
<option>Visitor Visa</option>
<option>Student Visa</option>
<option>Working Holiday Visa</option>
</select></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">When would you like to start your course?</font></font></td>
<td><label for="select2"></label>
<select name="select2" id="select2">
<option selected="selected">--Month--</option>
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
<label for="select3"></label>
<select name="select3" id="select3">
<option value="0">--Year--</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
<option>2014</option>
<option>2015</option>
</select></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Choose your course</font></font></td>
<td>
<label for="select5"></label>
<select name="select5" id="select5">
<option selected="selected">--Select--</option>
<option>Business English</option>
<option>English for Academic Purpose (EAP)</option>
<option>General Intensive English</option>
<option>IELTS</option>
</select>
<br />
</td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Period</font></font></td>
<td><label for="select9"></label>
<select name="select8" id="select9">
<option selected="selected">--Select--</option>
<option>Morning</option>
<option>Evening</option>
</select></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">How many weeks?</font></font></td>
<td><label for="select10">
<select name="select9" id="select8" onChange="calculaGeneral(this.value)">
<option>--Select--</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
</select>
</label></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Preparation Course For the Cambrigde Exams</font></font></td>
<td><label for="select11"></label>
<select name="select10" id="select11">
<option selected="selected">--Select--</option>
<option>Preliminary English Test (PET)</option>
<option>First Certificate in English (FCE)</option>
<option>Certificate in Advanced English (CAE)</option>
</select></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">How many weeks?</font></font></td>
<td><label for="select12"></label>
<select name="select11" id="select12" onChange="calculaPreparation(this.value)">
<option selected="selected">--Select--</option>
<option>10</option>
<option>12</option>
</select></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Enrolment Fee</font></font></td>
<td><label for="select7"></label>
<select name="select7" id="select7 onChange="calculaSemana(this.value)">
<option selected="selected">--Select--</option>
<option>Student Visa</option>
<option>Other Visa</option>
</select></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Materials Fees</font></font></td>
<td>
<label for="select4"></label>
<select name="select4" id="select4 onChange="calculaMaterial(this.value)">
<option selected="selected">--Select--</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
</select>
<br />
</td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">OSHC</font></font></td>
<td><label>
<select name="select12" id="select7" onChange="calculaOSHC(this.value)">
<option>--Select--</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
</select>
</label></td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Acommodation</font></font></td>
<td><input type="radio" name="radio3" id="radio3" value="radio3" />
<label for="radio3"></label>
Yes
<input type="radio" name="radio" id="radio" value="radio" />
<label for="radio"></label>
No</td>
</tr>
<tr>
<td bgcolor="#0691C1"><font color="#FFFFFF">Airport Pick up</font></font></td>
<td><input type="radio" name="radio4" id="radio4" value="radio4" />
<label for="radio4"></label>
Yes
<input type="radio" name="radio2" id="radio2" value="radio2" />
<label for="radio2"></label>
No</td>
</tr>
<tr></tr>
<tr>
<td align="right" valign="right" bgcolor="#0691C1"><font color="#FFFFFF"><strong>TOTAL</strong></font></font></td>
<td align="center" valign="middle"><strong><span id="SPAN_TOTAL">$ 0.0</span></strong></td>
</tr>
<tr></tr>
<tr>
<td colspan="2" align="center" valign="middle"><input type="reset" name="limpar" id="limpar" value="Clear" />
<input type="submit" name="enviar" id="enviar" value="Apply" /></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>

Editado por kuroi
Adicionar tag CODE
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...