Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 actions from a submit button? 1

Status
Not open for further replies.

EddieVenus

Technical User
Apr 8, 2002
176
US
Hello all,

I am new to this, and I have come a long way without knowing what I was doing. But now as I am figuring it out, I try to do more than my abilities allow for, and I run into problems. Most of which I can find answers to, as others have also run into such problems and posted their trial and tribulations here at Tek-Tips. For them I am grateful. Now my problem lies in that I have a page that takes form data from textboxes, that was in turn narrowed dowm with lists and menus, and updates the displayed record in an Access database. I want to make the action on the submit button do 2 things.
1) perform the update to the database
2) take the user to a page that shows them that they did update and what the new data is now.
Now I tried some javascript, but I must have done it wrong, and I though of an onclick event, but I don't know if they even work in this environment. I thought of some form of counter to see if this is the first time the page was displayed to this user, if so, then update, if not then go to the following display page. Any and all suggestions welcome. In fact, I am really ready to try anything, now that I vagley understand it, it is much more interesting.

thanks
ev
 
To check if a page has been viewed before you can use a session. But this only works if the user comes to your site, fills in the form, then trys to go back to the form again without closing there browser or waiting 20 minutes till the session times out..

If page1.asp is the page you want to check if the user has been at before then you put the following code on page1.asp

<%
If session(&quot;BeenHere&quot;) <> True 'if they havn't been here..
Session(&quot;BeenHere&quot;) = True 'Now they have been here

Else
Response.Redirect(&quot;youhavebeenhere.asp&quot;)
'or whatever you want to do with a user that has already been to this form.

End if

%>



page1.asp

The form..
Submit to page2.asp




page2.asp


<%

set my_conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
ConnString = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;database.mdb&quot;)

my_conn.Open ConnString

mySQL = &quot;UPDATE table_name SET column_name = '&quot; & column_value & &quot;' WHERE id=&quot; & IdNumber

rs = my_conn.Execute(mySQL)

'Redirect to a page..
response.redirect(&quot;complete.asp&quot;)

%>





jason@vzio.com
s_vzio.gif
 
oops, fixed the session code.. forgot then.. oh its late!

<%
If Session(&quot;BeenHere&quot;) <> True Then 'havnt been here

Session(&quot;BeenHere&quot;) = True 'Now they have been here

Else

Response.Redirect(&quot;youhavebeenhere.asp&quot;)

'or whatever you want to do with a user that has already been to this form.

End if

%> jason@vzio.com
s_vzio.gif
 
Thank you, that was amazingly helpful, it works like a charm. I had to put it in my code and mess around till I got it in right, but it is just what I needed. Thank you snowboardr. After all of that I also found on a followup page that Dreaweaver UltraDev has that function built in. Well you live and learn, besides I would rather know how than follow some prebuilt model without understanding it. Now I know, and knowing is 1/2 the battle.

ev
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top