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

Two Submit button problem

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I have a form with two buttons on it. My code for the first button works, but the code for the second button is doing nothing. I don't get any errors, and the page acts like it is doing the code, but when I actually look in the database nothing has happened. Here is the code. Any suggestions would be great.

<%
if request.Form(&quot;Update&quot;) = &quot;Submit&quot; Then
dbrs2.open (&quot;Select * From Timesheet where userID = '&quot; & request.form(&quot;employee1&quot;)& &quot;' and month = '&quot; & request.form(&quot;month1&quot;)& &quot;'&quot; ), dbconn, 2, 3
dbrs2.movefirst
Dim x
x = 1
do while NOT dbrs2.EOF

dbrs2(&quot;date&quot;)=request(&quot;date&quot; & x)
dbrs2(&quot;hour&quot;)=request.Form(&quot;hour&quot; & x)
dbrs2(&quot;code&quot;)=request(&quot;code&quot; & x)
dbrs2(&quot;approval&quot;)=request.Form(&quot;checkbox2&quot;)
dbrs2(&quot;approvedby&quot;)=request.Form(&quot;approvedby&quot;)
dbrs2.update
dbrs2.movenext
x = x + 1
loop
else if request.Form(&quot;Approve&quot;) = &quot;Submit&quot; Then
dbrs2.open (&quot;Select * From Timesheet where userID = '&quot; & request.form(&quot;employee1&quot;)& &quot;' and month = '&quot; & request.form(&quot;month1&quot;)& &quot;'&quot; ), dbconn, 2, 3
dbrs.open (&quot;Select * From employeeinfo where userID = '&quot; & request.form(&quot;employee&quot;)& &quot;'&quot;), dbconn, 2, 3
dbrs2.movefirst
x = 1
do while NOT dbrs2.EOF

dbrs2(&quot;date&quot;)=request(&quot;date&quot; & x)
dbrs2(&quot;hour&quot;)=request.Form(&quot;hour&quot; & x)
dbrs2(&quot;code&quot;)=request(&quot;code&quot; & x)
dbrs2(&quot;approval&quot;)=request.Form(&quot;checkbox2&quot;)
dbrs2(&quot;approvedby&quot;)=request.Form(&quot;approvedby&quot;)
dbrs2.update
dbrs2.movenext
x = x + 1
loop
Dim vacation
Dim overtime
Dim personal
vacation = (request.form(&quot;vacation&quot;).value - request.form(&quot;vacationtime&quot;).value)
overtime = (request.form(&quot;over_time&quot;).value * 0 + request.form(&quot;overtime&quot;).value)
personal = (request.form(&quot;personal&quot;).value - request.form(&quot;personaltime&quot;).value)
dbrs.movefirst
dbrs(&quot;vacationtime&quot;)= vacation
dbrs(&quot;overtime&quot;)= overtime
dbrs(&quot;personalTime&quot;)= personal
dbrs.update
dbrs.movenext

End if
End if
%>
 
Can you post the actual form page. Do you have two forms or just one form with two buttons. If you only have one form that the chances are it will always carry out the first part of the if statement. Even though you might click the Approve button, the UPdate button will still pass a value as it is still part of the form - at least I think it will.

try setting the value of a hidden variable when you click each button and then check the value of that hidden variable. Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top