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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Database without a redirect

Status
Not open for further replies.

uncgis

MIS
Apr 9, 2004
58
0
0
US
I have a webpage with 3 command buttons...
Read
Contacted
Print

Whenever a command button is selected for "Read" or "Contacted" it needs to update the database. Is there anyway to update the database without being redirected to another page...I guess I am looking for how to add a function to an command button or using onclick. Thanks for any help

 
something like this:

<input type="button" name="Contacted" OnClick='contacted();'>


<script language="javascript">
contacted()
{
alert("record is updated!!!")
window.location("yourpage.asp")
}
</script>

-DNG
 
thanks for replying...

where does the script go to update the database...on the yourpage.asp?

thanks
 
Are you wishing to do this with no page transition at all?

If so do a search on "xmlhttp
 
something like this, the code is not tested though...just tweak to make it work...

yourpage.asp
Code:
<%
if Request.Form("submit") = "Submit" then

dim conn, sql,myval

myval=request.form("formvalue")

set conn=server.createobject("adodb.connection"_

sql="UPDATE mytable set blah='blahblah' where recordid="&myval

conn.execute (sql)
end if
%>

<html>
<body>

<FORM METHOD="post" ACTION="yourpage.asp">

<input type="text" name="myvalue">
<input type="submit" name="Submit" value="Submit" onclick='contacted();'>

</form>
</body>
<script language="javascript">
contacted()
{
alert("record is updated!!!")
window.location("yourpage.asp")
}
</script>
<html>

-DNG
 
You could also use XMLHTTPRequest to make the call to update the database without ever leaving the page you're on.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Yes, XMLHTTPRequest is a very nice silent way! It is working for me.
 
I ended up using two pages to get the program to work...but can XMLHTTPRequest be used in asp.net and asp pages?

I would like to learn how to use it...but right now i am pushed for time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top