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

On Update Reset fields

Status
Not open for further replies.

acewilli

IS-IT--Management
Apr 11, 2003
98
US
What is the best way to clear the screen on an ASP page when the update button is pressed? I'm using VBScript. I will actually check the fields against a condition when the Update button is pressed and if the condition is true I will clear the screen and make the user start over. If the condition is false I will update the database. I just need to know how to clear the screen such as a reset button would do. Thanks in advance.

acewilli
 
If you want to clear it before the form is submitted to the server then you'll need to do that with client-side script instead of with ASP.

If you don't mind submitting everything to the server then just post it all and let the server-side ASP logic decide if the values should go into the database or the empty form should be re-displayed.

What is the actual behavior you want for your web page?
 
Is what I am doing is giving users 10 points that they can allocate to other users for voting purposes. I need to keep them from using more than 10 points or less than 0 points. I essentially need to keep them from typing in over 10 points or any negative numbers. I would like to check this before the database is updated and reset the screen to what it was before they typed in the over 10 points or negative numbers or just reset everything on the screen to 0 and make them enter in between 0 and 10 points. I sure hope that makes sense. I've included my Update function. Very sloppy I know but it works well. I sure hope you can help me figure this one out. I really would like to just be able to reset the client side to 0's if the user tries to enter in more than 10 points or less than 0 points before anything even goes to the database. Something like a "RESET" button would do if you clicked it except automatically. Thanks in advance.

Code:
dim strtotal, numpoints

If Request.Form("submit") = "Update" Then

While not rsStatus.eof
sID = rsStatus("ID")
smember= Replace(Trim(Request.Form("txtmember"& sID)),"'","''")
spoints= Replace(Trim(Request.Form("txtpoints"& sID)),"'","''")
snpoints= Replace(Trim(Request.Form("txtnpoints"& sID)),"'","''")
stpoints= Replace(Trim(Request.Form("txttpoints"& sID)),"'","''")
smopoints= Replace(Trim(Request.Form("txtmopoints"& sID)),"'","''")
syrpoints= Replace(Trim(Request.Form("txtyrpoints"& sID)),"'","''")
smemo= Replace(Trim(Request.Form("txtmemo"& sID)),"'","''")

If sID = "1" then
[COLOR=red]If npoints > "10" or npoints < "0" then
response.write "Your points are more than 10 or less than 0!"
Else[/color]
syrpoints = snpoints + smopoints
smopoints = snpoints
strSQL = "UPDATE Team SET yrpoints='"& syrpoints &"', mopoints='"& smopoints &"', memo='"& smemo &"', npoints='"& snpoints &"' WHERE ID='1'"
db.Execute strSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal from Team WHERE ID='1' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal from Team WHERE ID='1' ")
set rsc=db.execute ("SELECT memo as strmemo from Team WHERE ID='1' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo") &"', tyrpoints='"& rsy("strytotal") &"', tmopoints='"& rsm("strmtotal") &"' WHERE ID='1'"
db.Execute strHSQL
[COLOR=red]End If[/color]
else
[COLOR=red]If npoints > "10" or npoints < "0" then
response.write "Your points are more than 10 or less than 0!"
Else[/color]
syrpoints = snpoints + smopoints
smopoints = snpoints
strSQL = "UPDATE Team SET yrpoints='"& syrpoints &"', mopoints='"& smopoints &"', memo='"& smemo &"', npoints='"& snpoints &"' WHERE ID="& sID
db.Execute strSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal2 from Team WHERE ID='2' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal2 from Team WHERE ID='2' ")
set rsc=db.execute ("SELECT memo as strmemo2 from Team WHERE ID='2' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo2") &"', tyrpoints='"& rsy("strytotal2") &"', tmopoints='"& rsm("strmtotal2") &"' WHERE ID='2'"
db.Execute strHSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal3 from Team WHERE ID='3' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal3 from Team WHERE ID='3' ")			
set rsc=db.execute ("SELECT memo as strmemo3 from Team WHERE ID='3' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo3") &"', tyrpoints='"& rsy("strytotal3") &"', tmopoints='"& rsm("strmtotal3") &"' WHERE ID='3'"
db.Execute strHSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal4 from Team WHERE ID='4' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal4 from Team WHERE ID='4' ")				
set rsc=db.execute ("SELECT memo as strmemo4 from Team WHERE ID='4' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo4") &"', tyrpoints='"& rsy("strytotal4") &"', tmopoints='"& rsm("strmtotal4") &"' WHERE ID='4'"
db.Execute strHSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal5 from Team WHERE ID='5' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal5 from Team WHERE ID='5' ")				
set rsc=db.execute ("SELECT memo as strmemo5 from Team WHERE ID='5' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo5") &"', tyrpoints='"& rsy("strytotal5") &"', tmopoints='"& rsm("strmtotal5") &"' WHERE ID='5'"
db.Execute strHSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal6 from Team WHERE ID='6' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal6 from Team WHERE ID='6' ")				
set rsc=db.execute ("SELECT memo as strmemo6 from Team WHERE ID='6' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo6") &"', tyrpoints='"& rsy("strytotal6") &"', tmopoints='"& rsm("strmtotal6") &"' WHERE ID='6'"
db.Execute strHSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal7 from Team WHERE ID='7' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal7 from Team WHERE ID='7' ")				
set rsc=db.execute ("SELECT memo as strmemo7 from Team WHERE ID='7' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo7") &"', tyrpoints='"& rsy("strytotal7") &"', tmopoints='"& rsm("strmtotal7") &"' WHERE ID='7'"
db.Execute strHSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal8 from Team WHERE ID='8' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal8 from Team WHERE ID='8' ")				
set rsc=db.execute ("SELECT memo as strmemo8 from Team WHERE ID='8' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo8") &"', tyrpoints='"& rsy("strytotal8") &"', tmopoints='"& rsm("strmtotal8") &"' WHERE ID='8'"
db.Execute strHSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal9 from Team WHERE ID='9' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal9 from Team WHERE ID='9' ")				
set rsc=db.execute ("SELECT memo as strmemo9 from Team WHERE ID='9' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo9") &"', tyrpoints='"& rsy("strytotal9") &"', tmopoints='"& rsm("strmtotal9") &"' WHERE ID='9'"
db.Execute strHSQL
set rsm=db.execute ("SELECT SUM(Team.mopoints) as strmtotal10 from Team WHERE ID='10' ")
set rsy=db.execute ("SELECT SUM(Team.yrpoints) as strytotal10 from Team WHERE ID='10' ")				
set rsc=db.execute ("SELECT memo as strmemo10 from Team WHERE ID='10' ")
strHSQL = "UPDATE Home SET ttmemo='"& rsc("strmemo10") &"', tyrpoints='"& rsy("strytotal10") &"', tmopoints='"& rsm("strmtotal10") &"' WHERE ID='10'"
db.Execute strHSQL
[COLOR=red]End If[/color]
End If
rsStatus.movenext
rsHome.movenext
Wend
rsStatus.movefirst
rsHome.movefirst
set rs=db.execute ("Select SUM(npoints) as strtotal from team ")
stpoints = rsStatus("points") - rs("strtotal")
spoints = rsStatus("points")
strSQL = "UPDATE Team SET tpoints='"& stpoints &"', points='"& spoints &"' WHERE ID='1'"
db.Execute strSQL
End If
%>
 
Sheco, can you show me how to do what you suggested?

Thank you,

acewilli
 
I got it working perfectly. I can post my code if anyone would like. If not, I'm just going to call it quits on this post.

Thanks,

acewilli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top