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("D ate")
AuthName = Request.Form("A uthName")
EmpID = Request.Form("E mpID")
Comments = Request.Form("C omments")
Dim AccessOption1
Dim AccessOption2
Dim AccessOption3
Dim AccessOption4
Dim AccessOption5
If Request.Form("c hkStandard") = "1" Then
Response.Write( "1 = Checked<br>")
AccessOption1 = "1"
Else
Response.Write( "1 = Not Checked<br>")
AccessOption1 = "0"
End If
If Request.Form("c hkEmail") = "1" Then
Response.Write( "2 = Checked<br>")
AccessOption2 = "2"
Else
Response.Write( "2 = Not Checked<br>")
AccessOption2 = "0"
End If
If Request.Form("c hkVPN") = "1" Then
Response.Write( "3 = Checked<br>")
AccessOption3 = "3"
Else
Response.Write( "3 = Not Checked<br>")
AccessOption3 = "0"
End If
If Request.Form("c hkOtherNetwork" ) = "1" Then
Response.Write( "4 = Checked<br>")
AccessOption4 = "4"
Else
Response.Write( "4 = Not Checked<br>")
AccessOption4 = "0"
End If
If Request.Form("c hkPRAIS") = "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( "AccessOpti on" & i & " is not empty, therefore will be
inserted<br>")
'Insert 1 record for each option checked
Else
Response.Write( "AccessOpti on" & 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 8 1661
Drew wrote on 07 nov 2005 in microsoft.publi c.inetserver.as p.general: AccessOption5 = "0" End If
For i = 1 to 5 If (AccessOption & i) <> "0" Then
You cannot do this:
(AccessOption & i)
This does not make a variable name in ASP-VBS
Use an array:
dim AccessOption()
AccessOption(5) = "0"
i=5
If AccessOption(i) <> "0" Then
....
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.242.. . Drew wrote on 07 nov 2005 in microsoft.publi c.inetserver.as p.general:
AccessOption5 = "0" End If
For i = 1 to 5 If (AccessOption & i) <> "0" Then
You cannot do this:
(AccessOption & i) This does not make a variable name in ASP-VBS
But this does:
If Eval("AccessOpt ion" & i) <> "0" Then
McKirahan wrote: This does not make a variable name in ASP-VBS
But this does:
If Eval("AccessOpt ion" & i) <> "0" Then
Yeah, but Eval is evil :-)
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:uB******** ******@TK2MSFTN GP12.phx.gbl... McKirahan wrote:
This does not make a variable name in ASP-VBS
But this does:
If Eval("AccessOpt ion" & i) <> "0" Then
Yeah, but Eval is evil :-)
Why?
I understand that it is deprecated in JavaScript
but this is VBScript and it solves his problem.
Really overkill here. There is no point using Eval when you can use arrays
instead for both execution efficiency and clarity...
--
Patrice
"McKirahan" <Ne**@McKirahan .com> a écrit dans le message de
news:L4******** ************@co mcast.com... "Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message news:uB******** ******@TK2MSFTN GP12.phx.gbl... McKirahan wrote:
> This does not make a variable name in ASP-VBS
But this does:
If Eval("AccessOpt ion" & i) <> "0" Then
Yeah, but Eval is evil :-)
Why?
I understand that it is deprecated in JavaScript but this is VBScript and it solves his problem.
McKirahan wrote: "Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message news:uB******** ******@TK2MSFTN GP12.phx.gbl... McKirahan wrote:
This does not make a variable name in ASP-VBS
But this does:
If Eval("AccessOpt ion" & i) <> "0" Then
Yeah, but Eval is evil :-)
Why?
Mainly, because it starts another compiler. Instead of a single compiler
being applied to your code, you now have two compliers being spawned to,
well, compile the code. See: http://blogs.msdn.com/ericlippert/ar.../01/53329.aspx
Eval has its places, but its use should be considered as an absolute last
resort. In this case, there is a much better solution available (the array),
so eval should not be considered.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows [MVP] wrote: McKirahan wrote: "Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message news:uB******** ******@TK2MSFTN GP12.phx.gbl... McKirahan wrote:
> This does not make a variable name in ASP-VBS
But this does:
If Eval("AccessOpt ion" & i) <> "0" Then
Yeah, but Eval is evil :-)
Why?
Mainly, because it starts another compiler. Instead of a single compiler being applied to your code, you now have two compliers being spawned to, well, compile the code. See: http://blogs.msdn.com/ericlippert/ar.../01/53329.aspx
Oh! and don't forget to look at Part 2: http://blogs.msdn.com/ericlippert/ar.../04/53335.aspx
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Thanks for all the replies... I ended up using the array method.
Thanks,
Drew This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: neblackcat |
last post by:
Would anyone like to comment on the following idea?
I was just going to offer it as a new PEP until it was suggested that
I post it here for comment & consideration against PEP 308.
I'm far from being a "language internist" (on Python or anything else)
so go easy on me if this is stupid - it just seemed quite elegant to
me as a relative...
|
by: Guy Hocking |
last post by:
Hi there,
I am having a few problems compiling a list box that is conditional on what
is selected in another list box.
What i need is a List box (lstArea) that displays one thing when the List
Box (lstRegion) is selected East or West. Basically the areas will change
when East or West is selected in lstRegion.
The data comes from an SQL...
|
by: Dimitri Furman |
last post by:
Given:
Access 2002/2003
A subform in datasheet or continuous view, placed on a tab page (this last
may or may not matter)
Conditional formatting applied to some controls on the subform -
format expressions are the same for all controls
Under some undetermined circumstances, when such subform is displayed, the
controls on the subform start...
|
by: Raghavendra R A V, CSS India |
last post by:
hie..
Do any one knows how to write a C program without using the
conditional statements if, for, while, do, switch, goto and even
condotional statements ? It would be a great help for me if someone
helps me...
Urgent - Please reply soon !
Thanks, Raghu
|
by: Typehigh |
last post by:
I have many text fields with conditional formatting applied,
specifically when the condition is "Field Has Focus". Without any
events associated with the fields the conditional formatting works
perfectly. However, I have code that runs under the ON CLICK event. The
code changes the focus to other controls, which means the conditional...
| |
by: dev_cool |
last post by:
Hello friends,
I'm a beginner in C programming. One of my friends asked me to write a
program in C.The purpose of the program is print 1 to n without any
conditional statement, loop or jump.
How is it possible? Please help me.
Thanks in advance.
|
by: Klauer |
last post by:
Hello all,
I'm kind of new to working with C++, and I have an issue in solving an
issue that maybe someone out here can help me with.
I have a piece of code in this project that I'm tasked to try to fix
some minor errors. One of these errors is dealing with XML and
loading in an XML file. The XML file is created by a couple different...
|
by: afromanam |
last post by:
Regards,
Please help
What I'm trying to do is this: (and I can't use reports since I must export to Excel)
I export some queries to different tabs in an excel workbook
I then loop through each tab and apply autowidth to columns and apply autofilter to the first row of every tab in the workbook. I've this down
|
by: jschrader |
last post by:
I am trying to write a conditional Statement in ASP based on dates/times in a database entry.
I'm basically a ASP/web designer and try my best to get into the fun coding, so not sure as to the syntax of what I'm trying to do...
The structure I'm working on is
Database Connection
Select DB record occuring "Today" - have this working with...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |