• 0
Sign in to follow this  
Jorge Roman

Refresh Of Page And Onclick Event In Form

Question

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>

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 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.

Share this post


Link to post
Share on other 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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this