Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Igor FV

Carregar 2 funções no Body, como?

Recommended Posts

Boa tarde,

 

Gostaria de carregar 2 funções com nomes diferentes no BODY com o onLoad, porém somente a 1º está sendo carregada. Tem como carregar mais de 1 função no BODY?

 

 

FUNÇÕES:

 

 

<script language="JavaScript" type="text/javascript">function calc_perg01() {var porc_insat_perg01 =((Number(document.getElementById("opc_011").value) + Number(document.getElementById("opc_012").value))*100)/((Number(document.getElementById("opc_011").value))+ Number(document.getElementById("opc_012").value)+ Number(document.getElementById("opc_013").value)+ Number(document.getElementById("opc_014").value)+ Number(document.getElementById("opc_015").value));document.getElementById("porc_insat_perg01").value = porc_insat_perg01.toFixed(2);var porc_indif_perg01 = ((Number(document.getElementById("opc_011").value))*100)/((Number(document.getElementById("opc_011").value))+ Number(document.getElementById("opc_012").value)+ Number(document.getElementById("opc_013").value)+ Number(document.getElementById("opc_014").value)+ Number(document.getElementById("opc_015").value));document.getElementById("porc_indif_perg01").value = porc_indif_perg01.toFixed(2);var porc_sat_perg01 = ((Number(document.getElementById("opc_014").value) + Number(document.getElementById("opc_015").value))*100)/((Number(document.getElementById("opc_011").value))+ Number(document.getElementById("opc_012").value)+ Number(document.getElementById("opc_013").value)+ Number(document.getElementById("opc_014").value)+ Number(document.getElementById("opc_015").value));document.getElementById("porc_sat_perg01").value = porc_sat_perg01.toFixed(2);}function calc_perg02() {var porc_insat_perg02 =((Number(document.getElementById("opc_021").value) + Number(document.getElementById("opc_012").value))*100)/((Number(document.getElementById("opc_021").value))+ Number(document.getElementById("opc_022").value)+ Number(document.getElementById("opc_023").value)+ Number(document.getElementById("opc_024").value)+ Number(document.getElementById("opc_025").value));document.getElementById("porc_insat_perg02").value = porc_insat_perg02.toFixed(2);var porc_indif_perg02 = ((Number(document.getElementById("opc_021").value))*100)/((Number(document.getElementById("opc_021").value))+ Number(document.getElementById("opc_022").value)+ Number(document.getElementById("opc_023").value)+ Number(document.getElementById("opc_024").value)+ Number(document.getElementById("opc_025").value));document.getElementById("porc_indif_perg02").value = porc_indif_perg02.toFixed(2);var porc_sat_perg02 = ((Number(document.getElementById("opc_024").value) + Number(document.getElementById("opc_025").value))*100)/((Number(document.getElementById("opc_011").value))+ Number(document.getElementById("opc_022").value)+ Number(document.getElementById("opc_023").value)+ Number(document.getElementById("opc_024").value)+ Number(document.getElementById("opc_025").value));document.getElementById("porc_sat_perg02").value = porc_sat_perg02.toFixed(2);}</script>

 

Valeu amigos.....

 

 

Dessaa forma só esta sendo carregada a 1º:

 

<body onLoad="calc_perg01(); calc_perg02();">

 

 

Como carregar a 2º função?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Po amigo infelizmente não ta na web......... nem tem como você dar uma olhada......... na web..... mas posso explicar melhor..........A 2º função carrega os valores em diferentes campos do tipo TEXT de formulario... O problema ta quando eu coloco a 2º função pra carregar no BODY, não funciona.....será q tenho q passar algum parametro?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Aqui esta o form onde quero exibir os resultados da função:

<body onLoad="calc_perg01();calc_perg02();"><form id="form_relatorio" name="form_relatorio" method="POST"> <table width="608" height="3570" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="20" colspan="3" rowspan="5"> <div align="left"> <input name="imageField" type="image" src="imagens/jpeg/logo_alcape.jpg" align="left" /> </div></td> <td height="10"> </td> <td height="0"> </td> <td height="0"> </td> <td height="0"> </td> <td height="0"> </td> <td height="0"> </td> </tr> <tr> <td height="5" colspan="2" class="STILO"><div align="left" class="TITULO">Razão Social:</div></td> <td height="5" colspan="4"><input name="razao_social" type="text" id="razao_social" size="50" /></td> </tr> <tr> <td height="5" colspan="2" class="TITULO"><div align="left">Total Empregados:</div></td> <td height="5"><div align="left"> <input name="soma_tot_empreg" type="text" id="soma_tot_empreg" size="5" /> </div></td> <td height="5"> </td> <td height="5"> </td> <td height="5"> </td> </tr> <tr> <td height="5" colspan="2" class="TITULO"><div align="left">Total Entrevistados:</div></td> <td height="5"> <div align="left"> <input name="soma_tot_entrev" type="text" id="soma_tot_entrev" size="5" /> </div></td> <td height="5"> </td> <td height="5"> </td> <td height="5"> </td> </tr> <tr> <td height="5"> </td> <td height="5"> </td> <td height="5"> </td> <td height="5"> </td> <td height="5"> </td> <td height="5"> </td> </tr> <tr> <td height="20" colspan="9"> </td> </tr> <tr> <td height="20" colspan="9"> </td> </tr> <tr> <td height="20" colspan="9" bgcolor="#66CCCC"><div align="center"><span class="TITULO">RELAÇÃO COM O TRABALHO</span></div></td> </tr> <tr> <td height="20" colspan="9"> </td> </tr> <tr> <th height="20" bgcolor="#CCCCCC" class="STILO" scope="row"><div align="center" class="style11"></div></th> <td width="66" height="20" bgcolor="#CCCCCC" class="TITULO"><div align="center" class="style11">1 </div></td> <td width="67" height="20" bgcolor="#CCCCCC" class="TITULO"><div align="center" class="style11">2</div></td> <td width="49" height="20" bgcolor="#CCCCCC" class="TITULO"><div align="center" class="style11">3</div></td> <td width="70" height="20" bgcolor="#CCCCCC" class="TITULO"><div align="center" class="style11">4</div></td> <td width="64" height="20" bgcolor="#CCCCCC" class="TITULO"><div align="center" class="style11">5</div></td> <th width="97" height="20" bgcolor="#CCCCCC" class="STILO" scope="row"><div align="center" class="style4">INSATISFEITO </div></th> <th width="97" height="20" bgcolor="#CCCCCC" class="STILO" scope="row"><div align="center" class="style4">INDIFERENTE </div></th> <th width="97" height="20" bgcolor="#CCCCCC" class="STILO" scope="row"><div align="center" class="style4"><span class="style5">SATISFEITO </span></div></th> </tr> <tr> <td height="20" colspan="9" class="TITULO"> </td> </tr> <tr> <td width="28" height="20" class="TITULO"><div align="center" class="style11">1 -</div></td> <td width="66" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_011" type="text" id="opc_011" value="<?php echo $RES_OPC_011['soma_opc_011'] ?>" size="5" /> </div></td> <td width="67" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_012" type="text" id="opc_012" value="<?php echo $RES_OPC_012['soma_opc_012'] ?>" size="5" /> </div></td> <td width="49" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_013" type="text" id="opc_013" value="<?php echo $RES_OPC_013['soma_opc_013'] ?>" size="5" /> </div></td> <td width="70" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_014" type="text" id="opc_014" value="<?php echo $RES_OPC_014['soma_opc_014'] ?>" size="5" /> </div></td> <td width="64" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_015" type="text" id="opc_015" value="<?php echo $RES_OPC_015['soma_opc_015'] ?>" size="5" /> </div></td> <td class="style12"><div align="center"><span class="style11"> <input name="porc_insat_perg01" type="text" id="porc_insat_perg01"size="5" /> </span></div></td> <td class="style12"><div align="center"><span class="style11"> <input name="porc_indif_perg01" type="text" id="porc_indif_perg01"size="5" /> </span></div></td> <td class="style12"><div align="center"><span class="style11"> <input name="porc_sat_perg01" type="text" id="porc_sat_perg01"size="5" /> </span></div></td> </tr> <tr> <td width="28" height="20" class="TITULO"><div align="center" class="style11">2 -</div></td> <td width="66" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_021" type="text" id="opc_021" value="<?php echo $RES_OPC_021['soma_opc_021'] ?>" size="5" /> </div></td> <td width="67" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_022" type="text" id="opc_022" value="<?php echo $RES_OPC_022['soma_opc_022'] ?>" size="5" /> </div></td> <td width="49" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_23" type="text" id="opc_23" value="<?php echo $RES_OPC_023['soma_opc_023'] ?>" size="5" /> </div></td> <td width="70" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_024" type="text" id="opc_024" value="<?php echo $RES_OPC_024['soma_opc_024'] ?>" size="5" /> </div></td> <td width="64" height="20" class="TITULO"><div align="center" class="style11"> <input name="opc_025" type="text" id="opc_025" value="<?php echo $RES_OPC_025['soma_opc_025'] ?>" size="5" /> </div></td> <td width="97" class="style12"><div align="center"><span class="style11"> <input name="porc_insat_perg02" type="text" id="porc_insat_perg02"size="5" /> </span></div></td> <td width="97" class="style12"><div align="center"><span class="style11"> <input name="porc_indef_perg02" type="text" id="porc_indef_perg02"size="5" /> </span></div></td> <td width="97" class="style12"><div align="center"><span class="style11"> <input name="porc_sat_perg02" type="text" id="porc_sat_perg02"size="5" /> </span></div></td>

So a 2º não funciona.........os valores não são carregados nos campos de form designados....estranho.........Amigo... consegui resolver...........o problema estava no name do campo............. estava errado..............ai não estava rodando a função.....Valeu amigo.............um abraço...........e obrigado pela ajuda.............

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.