Because the asp processor on the server first processes the asp tags, and
then sends the resulting HTML down to the client, where the client side
script function verifica() may or may not be invoked.  In the client side IF
statement, the two branches will contain/include the output (from
response.write) of the two asp functions contar() and Descontar().

HTH,
Tore.

----- Original Message -----
From: "Mario Lopes" <[EMAIL PROTECTED]>
To: "ActiveServerPages" <[EMAIL PROTECTED]>
Sent: Monday, November 04, 2002 1:28 PM
Subject: I can�t believe


>
> Why the folling function executes both asp sub's?
>
>
> <SCRIPT LANGUAGE="Javascript">
> <!-- Beginning of JavaScript -
> function verifica(opcao,certa){
>
>  alert(opcao+" "+certa)
>
>  if (opcao==certa){
>   Certo()
>   <% contar() %>
>
>  } else
>   {
>   Errado()
>   <% Descontar() %>
>
>  }
> }
> // - End of JavaScript - -->
> </SCRIPT>
>
>
>
> <%
> sub Descontar()
> session("pontos")=session("pontos")-session("perdepontos")
>
>  Set MyConn=Server.CreateObject("ADODB.Connection")
> MyConn.Open "DSN=esabnet"
>
> sqlstmt="update alunos set pontos="&session("pontos") &" where
> nome='"&session("nome")&"'"
> Set MyRs=MyConn.Execute(sqlstmt)
>
> MyConn.Close
> set MyConn=nothing
> end sub %>
> <%
> sub Contar()
> session("pontos")=session("pontos")+session("ganhapontos")
>
>  Set MyConn=Server.CreateObject("ADODB.Connection")
> MyConn.Open "DSN=esabnet"
>
> sqlstmt="update alunos set pontos="&session("pontos") &" where
> nome='"&session("nome")&"'"
> Set MyRs=MyConn.Execute(sqlstmt)
>
> MyConn.Close
> set MyConn=nothing
>
> end sub %>
>
>
>
>
> ---
> You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
> To unsubscribe send a blank email to
%%email.unsub%%
>


---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to