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

Refresh Of Page And Onclick Event In Form


Jorge Roman

Pergunta

I have a code that use a variable session to control what it must be shown of the page.

The first time that the page is to be loading, a form of data is appears. If the user click in the button submit of the form, the records are save in the database and appear the message "the data had been recorded". If the user refresh the page must be appear another message, for example, "Page expired".

The first time that the page is to be loading the variable session comes with de value 0.

When the user click in the button submit (onclick event) the variable session assumes the value 100.

The problem is:

- when the user refresh the page, the variable session assumes value 100 and the records are to be saved in the database, instead of appearing the message “Page expired”.

What can i do? Thanks.

The code of "page.asp":

...
<BODY>
...
     <% If Session("conta")=0 Then %>
         ...
         <form action="page.asp">
              ...
              <input type="submit" value="SAVE"
                                    onclick='<% Session("conta")=100 %>'>
         </form>
     <% ElseIf Session("conta")=100 Then %>
         ...
         <p>The data had been recorded!</P>
         <% Session("conta")=33 %>
     <% Else %>
         ...
         <p>Page expired!</P>
     <% End If %>
...
</body>

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

this code:

              <input type="submit" value="SAVE"
                                    onclick='<% Session("conta")=100 %>'>[/code]

will not work. you can't mix javascript and asp this way. this code will always be executed, wether the user click the button or not.

what you can do is create an input type = "hidden" to control if the page is being submited or not

example, if this input is named "xxx", test if the request("xxx") has some value. if it does it is because the page has been submitted.

Link para o comentário
Compartilhar em outros sites

  • 0

hello....

in my works always use request.querystring("var"):

see

<form name="form" action="page.asp?x=1" method="post">
x=1 indicates the send form...
<%
if request.querystring("x")=1 then

'running program

else

%>
<form....
</form>
<% end if %>

ok... any doubts is so to ask

Link para o comentário
Compartilhar em outros sites

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,1k
    • Posts
      651,8k
×
×
  • Criar Novo...