D
Drew
I am building an application for keeping track of user permissions here at
work. I have built the interfaces, and am now working on the processing
page for inserting to the database. I am having a problem with a
conditional in my loop not working correctly, I am sure that I have been
overlooking something, but cannot pin it down.
I have pared the code down quite a bit just so that I could resolve my
issues with it. I have a page named addAIMR.asp that has about 34
checkboxes, 2 dropdowns and 2 textboxes. I am trying to something like
this,
If checkbox is checked
AccessOption1 = 1 (which is the access option number)
Else
AccessOption1 = 0
End If
Then I am trying to loop through the code to insert only the ones that <> 0.
This should be rather straight forward, but I am running into issues... I
have inserted many Response.Write's throughout the code to see the
variables, and everything looks kosher, until it gets to the loop, then it
shows that it would insert all the records.
Here is my code for processAIMR.asp,
<%
Dim AIMRDate
Dim AuthName
Dim EmpID
Dim Comments
AIMRDate = Request.Form("Date")
AuthName = Request.Form("AuthName")
EmpID = Request.Form("EmpID")
Comments = Request.Form("Comments")
Dim AccessOption1
Dim AccessOption2
Dim AccessOption3
Dim AccessOption4
Dim AccessOption5
If Request.Form("chkStandard") = "1" Then
Response.Write("1 = Checked<br>")
AccessOption1 = "1"
Else
Response.Write("1 = Not Checked<br>")
AccessOption1 = "0"
End If
If Request.Form("chkEmail") = "1" Then
Response.Write("2 = Checked<br>")
AccessOption2 = "2"
Else
Response.Write("2 = Not Checked<br>")
AccessOption2 = "0"
End If
If Request.Form("chkVPN") = "1" Then
Response.Write("3 = Checked<br>")
AccessOption3 = "3"
Else
Response.Write("3 = Not Checked<br>")
AccessOption3 = "0"
End If
If Request.Form("chkOtherNetwork") = "1" Then
Response.Write("4 = Checked<br>")
AccessOption4 = "4"
Else
Response.Write("4 = Not Checked<br>")
AccessOption4 = "0"
End If
If Request.Form("chkPRAIS") = "1" Then
Response.Write("5 = Checked<br>")
AccessOption5 = "5"
Else
Response.Write("5 = Not Checked<br>")
AccessOption5 = "0"
End If
For i = 1 to 5
If (AccessOption & i) <> "0" Then
Response.Write("AccessOption" & i & " is not empty, therefore will be
inserted<br>")
'Insert 1 record for each option checked
Else
Response.Write("AccessOption" & i & " is empty, therefore will NOT be
inserted<br>")
End If
Next
%>
If I check 2 boxes, chkStandard and chkVPN, then I get the following written
to the page,
1 = Checked
2 = Not Checked
3 = Checked
4 = Not Checked
5 = Not Checked
AccessOption1 is not empty, therefore will be inserted
AccessOption2 is not empty, therefore will be inserted
AccessOption3 is not empty, therefore will be inserted
AccessOption4 is not empty, therefore will be inserted
AccessOption5 is not empty, therefore will be inserted
Can anyone spot where I am going awry?
TIA,
Drew
work. I have built the interfaces, and am now working on the processing
page for inserting to the database. I am having a problem with a
conditional in my loop not working correctly, I am sure that I have been
overlooking something, but cannot pin it down.
I have pared the code down quite a bit just so that I could resolve my
issues with it. I have a page named addAIMR.asp that has about 34
checkboxes, 2 dropdowns and 2 textboxes. I am trying to something like
this,
If checkbox is checked
AccessOption1 = 1 (which is the access option number)
Else
AccessOption1 = 0
End If
Then I am trying to loop through the code to insert only the ones that <> 0.
This should be rather straight forward, but I am running into issues... I
have inserted many Response.Write's throughout the code to see the
variables, and everything looks kosher, until it gets to the loop, then it
shows that it would insert all the records.
Here is my code for processAIMR.asp,
<%
Dim AIMRDate
Dim AuthName
Dim EmpID
Dim Comments
AIMRDate = Request.Form("Date")
AuthName = Request.Form("AuthName")
EmpID = Request.Form("EmpID")
Comments = Request.Form("Comments")
Dim AccessOption1
Dim AccessOption2
Dim AccessOption3
Dim AccessOption4
Dim AccessOption5
If Request.Form("chkStandard") = "1" Then
Response.Write("1 = Checked<br>")
AccessOption1 = "1"
Else
Response.Write("1 = Not Checked<br>")
AccessOption1 = "0"
End If
If Request.Form("chkEmail") = "1" Then
Response.Write("2 = Checked<br>")
AccessOption2 = "2"
Else
Response.Write("2 = Not Checked<br>")
AccessOption2 = "0"
End If
If Request.Form("chkVPN") = "1" Then
Response.Write("3 = Checked<br>")
AccessOption3 = "3"
Else
Response.Write("3 = Not Checked<br>")
AccessOption3 = "0"
End If
If Request.Form("chkOtherNetwork") = "1" Then
Response.Write("4 = Checked<br>")
AccessOption4 = "4"
Else
Response.Write("4 = Not Checked<br>")
AccessOption4 = "0"
End If
If Request.Form("chkPRAIS") = "1" Then
Response.Write("5 = Checked<br>")
AccessOption5 = "5"
Else
Response.Write("5 = Not Checked<br>")
AccessOption5 = "0"
End If
For i = 1 to 5
If (AccessOption & i) <> "0" Then
Response.Write("AccessOption" & i & " is not empty, therefore will be
inserted<br>")
'Insert 1 record for each option checked
Else
Response.Write("AccessOption" & i & " is empty, therefore will NOT be
inserted<br>")
End If
Next
%>
If I check 2 boxes, chkStandard and chkVPN, then I get the following written
to the page,
1 = Checked
2 = Not Checked
3 = Checked
4 = Not Checked
5 = Not Checked
AccessOption1 is not empty, therefore will be inserted
AccessOption2 is not empty, therefore will be inserted
AccessOption3 is not empty, therefore will be inserted
AccessOption4 is not empty, therefore will be inserted
AccessOption5 is not empty, therefore will be inserted
Can anyone spot where I am going awry?
TIA,
Drew