|
-
Sep 1st, 2000, 01:59 PM
#1
Thread Starter
New Member
If want the information that is in a form to go into the querystring you have to set the form method to 'get'. When you are using the the 'post' method you retrieve the information using:
request.form("fieldname")
Where the fieldname is the name you assigned to the control on the form. It is usaully advisable to use the post method if you can when sending information to a database, since a querystring is limited in size. And use the query string when you want to pass variable used for retrieving information etc.
-
Sep 1st, 2000, 02:04 PM
#2
Lively Member
ajc,
Could you post (no pun intended) some code using the post method to pass information to a page that will perform an update on a database.
Also I've got another question. The addevent page is a popup window that is opened when a user clicks on the link to add an event. When the user clicks the save button on the addevent page I want it to add the record to the database and then close itself and refresh the main.asp page. If you could help me with this I would appreciate it.
Thanks.
[Edited by ttingen on 09-01-2000 at 03:17 PM]
-
Sep 1st, 2000, 03:37 PM
#3
Thread Starter
New Member
For using the post method, the personinfo.asp page is the one with your form. The postdown.asp is the page that is actually saving to the database.
------------------PersonInfo.asp-------------------------------
<form name="info" Action="postdown.asp" Method="post" onSubmit="return VerifyData()">
<p align="left">
<i><b>Name </b></i><br>
<input type="text" name="person" size="15">
<i><b>E-mail </b></i>
<input type="text" name="email" size="15">
</p>
<input type="submit" name="Submit" value="Submit">
</form>
--------------Postdown.asp page---------------------------------
<%
DimrsPost
Set rsPost = Server.CreateObject("ADODB.Recordset")
rsPost.Open "contact", db, adOpenForwardOnly, adLockOptimistic, adCmdTable
rsPost.AddNew
rsPost("name") = Request.Form("person")
rsPost("email") = Request.Form("email")
rsPost.Update
Response.Redirect "personInfo.asp"
%>
One way to automatically close the page after updating the database is to pass back a variable in the querystring and then using asp and javascript close the window. To do this you could change your response.redirect to
Response.Redirect "personInfo.asp?ul=1"
Then put in your code in the page with the form (in the example it would be personinfo.asp)
<html>
<head>
<script language= "Javascript">
<!--
function CloseWin(){
window.close()
}
-->
</script>
</head>
<%
if request.querystring("ul") = 1 then
response.write "<body onload='CloseWin()'>"
else
response.write "<body>"
end if
%>
//your form and whatever else.
</body>
</html>
This will test the querystring and if there is a 1 in the ul then it will write the body tag that calls the closewin()
method.
As for refreshing the other page, I don't know of anyway you could can do that from another window.
I hope this helps. One thing with IE5 is that when you call the window.close() IE pops up an alert saying the the window is trying to be closed by the web page. If you or anyone knows if there is a way to get around this could you please post that. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|