I want to use a Form to display/get fields from a table - problem is, I do
not know how many records the query will pull up. I have been trying to use
an array to identify the NAME=" " value, but have not been able to do so. I
want it to come up with something like
size="30"
VALUE="<%=(RStmpEvents("Event"))%>">
Everything but the NAME works. I've tried
NAME="aText<%=incDays%>"
NAME=<%=aText(incDays)%>
But just cannot seem to put a unique value to the NAME property. Here is the
code on the form and I expect to pick up anything from 0 to about 14
records. I want to be able to then refer to them as
aText(1) = whatever
aText(2) = whatever etc.
Dim aText() ' declare the array but at this point I don't know
how many elements it will have
Dim incDays ' to increment incDays = incDays + 1
Dim iDays ' this will count how many records match my
query
Set RSEvents = conn.Execute(sqltmpEvents)
' I loop through the query here to count how many records and put the value
in iDays
reDim aText(iDays) ' reset the array
incDays = 1 'start with day 1
%>
<%
The problem is that I CANNOT create the individual NAME= so that I can
reference the input - I am tearing my hair out!!
Laura TD
Re: Form fields array
am 23.03.2005 17:04:13 von unknown
Hi Laura,
A number of things. One, arrays in VBScript are zero-based, meaning that
your first value would be aText(0), not aText(1).
You create an array, but you never put any values in it, so aText(incDays)
will always be empty.
You don't need to use an array for what you're doing, if I followed you
right. You just want to have your text fields named with incrementing
numbers? If so, try this:
<%
Dim i
i = 1 'or 0, or any number, really
%>
But what are you going to do with this data after it's submitted? All
you're going to have is a bunch of textboxes with numeric names that you
won't be able to tie back to a specific record in your database. Does your
events table have a primary key? Why not bring that back in your query and
name your textboxes with that?
Ray at work
"laura" wrote in message
news:uFOifLzLFHA.1144@TK2MSFTNGP09.phx.gbl...
> I want to use a Form to display/get fields from a table - problem is, I do
> not know how many records the query will pull up. I have been trying to
use
> an array to identify the NAME=" " value, but have not been able to do so.
I
> want it to come up with something like
>
> size="30"
> VALUE="<%=(RStmpEvents("Event"))%>">
>
> Everything but the NAME works. I've tried
>
> NAME="aText<%=incDays%>"
> NAME=<%=aText(incDays)%>
>
> But just cannot seem to put a unique value to the NAME property. Here is
the
> code on the form and I expect to pick up anything from 0 to about 14
> records. I want to be able to then refer to them as
>
> aText(1) = whatever
> aText(2) = whatever etc.
>
> Dim aText() ' declare the array but at this point I don't
know
> how many elements it will have
> Dim incDays ' to increment incDays = incDays + 1
> Dim iDays ' this will count how many records match my
> query
> Set RSEvents = conn.Execute(sqltmpEvents)
> ' I loop through the query here to count how many records and put the
value
> in iDays
> reDim aText(iDays) ' reset the array
> incDays = 1 'start with day 1
> %>
>
> <%
>
> The problem is that I CANNOT create the individual NAME= so that I can
> reference the input - I am tearing my hair out!!
>
> Laura TD
>
>
Re: Form fields array
am 23.03.2005 19:10:54 von Laura
Hello Ray at work.
Boy, I've spent so much time on this.. trying so many permutations - even
getting up at 3.00 a.m. to try something (it didn't work). Finally, though,
this morning I did get something to work... sort of along the lines you were
recommending. I see your point about the array being empty.. I was getting
myself in a twist about it all.
I'm doing a travel and absence program where employees can enter their trip
dates - start, end etc.. and fill in the locations they visit (events). I
had to give them blank text boxes based on the number of days between start
and end. I did not know if it would be 1 or 14 or how many it would be, so I
didn't know what the text box would be named.
I am using a temporary database to do this - The records that I am
retrieving come from another database where existing trips have already been
recorded - I have to allow for the fact that they might be entering more
trips to one they had entered previously (or just amend the records). It's
all a bit complicated.. but what I was trying to achieve was that NAME=?
text box.
What I did in the end is similar to what you suggested-
Dim aText
Dim incDays
incDays=0
">
incDays = incDays + 1
I was then able to pick up any one of the records with
for counter=0 to iDays 'iDays are the count of how many days between
start and end dates
response.write(" aText = " request.form("aText" & counter))
next
I can refer to them as aText1 or aText2 etc.. and IT WORKS!! Hope this
makes sense?
Thanks for your input - I was getting punch-drunk, but I'm getting near to
completing this first ASP/Database project
Laura
"Ray Costanzo [MVP]" wrote in
message news:eR0y2H8LFHA.2888@TK2MSFTNGP12.phx.gbl...
> Hi Laura,
>
> A number of things. One, arrays in VBScript are zero-based, meaning that
> your first value would be aText(0), not aText(1).
>
> You create an array, but you never put any values in it, so aText(incDays)
> will always be empty.
>
> You don't need to use an array for what you're doing, if I followed you
> right. You just want to have your text fields named with incrementing
> numbers? If so, try this:
>
> <%
> Dim i
> i = 1 'or 0, or any number, really
> %>
>
>
>
> But what are you going to do with this data after it's submitted? All
> you're going to have is a bunch of textboxes with numeric names that you
> won't be able to tie back to a specific record in your database. Does
> your
> events table have a primary key? Why not bring that back in your query
> and
> name your textboxes with that?
>
> Ray at work
>
>
>
> "laura" wrote in message
> news:uFOifLzLFHA.1144@TK2MSFTNGP09.phx.gbl...
>> I want to use a Form to display/get fields from a table - problem is, I
>> do
>> not know how many records the query will pull up. I have been trying to
> use
>> an array to identify the NAME=" " value, but have not been able to do so.
> I
>> want it to come up with something like
>>
>> size="30"
>> VALUE="<%=(RStmpEvents("Event"))%>">
>>
>> Everything but the NAME works. I've tried
>>
>> NAME="aText<%=incDays%>"
>> NAME=<%=aText(incDays)%>
>>
>> But just cannot seem to put a unique value to the NAME property. Here is
> the
>> code on the form and I expect to pick up anything from 0 to about 14
>> records. I want to be able to then refer to them as
>>
>> aText(1) = whatever
>> aText(2) = whatever etc.
>>
>> Dim aText() ' declare the array but at this point I don't
> know
>> how many elements it will have
>> Dim incDays ' to increment incDays = incDays + 1
>> Dim iDays ' this will count how many records match my
>> query
>> Set RSEvents = conn.Execute(sqltmpEvents)
>> ' I loop through the query here to count how many records and put the
> value
>> in iDays
>> reDim aText(iDays) ' reset the array
>> incDays = 1 'start with day 1
>> %>
>>
>> <%
>>
>> The problem is that I CANNOT create the individual NAME= so that I can
>> reference the input - I am tearing my hair out!!
>>
>> Laura TD
>>
>>
>
>