Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Extract final field in row which has a value - an array issue perhaps?

Reply
Thread Tools

Extract final field in row which has a value - an array issue perhaps?

 
 
jason
Guest
Posts: n/a
 
      12-09-2003
Access 2000

I need some help interogatting a table and extracting via ASP the final
field in a row which has a value. In other words, I have a maximum of 10
fields but, at the user level he may he only enter values into the first
four. I need to ALWAYS extract the final or last field that has a value. In
the example below this would be PriceField5 which has a value of $162,000.

The user stopped at this field and left the rest blank.

I considered cycling through the row and checking for null or empty values
but I suspect this may be very messy and have not had much success in the
past. Is there a better more elegant way to achieve my goal?

--PRICE TABLE--
PriceField1 (eg 100,000)
PriceField2 (eg 130,000)
PriceField3 (eg 142,000)
PriceField4 (eg 152,000)
PriceField5 (eg 162,000)
PriceField6 (empty)
PriceField7 (empty)
PriceField8 (empty)
PriceField9 (empty)
PriceField10 (empty)

Many thanks in advance

Jason







 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      12-09-2003
I would think that looping would be okay for this. What are you trying to
do or why haven't you had luck with that?

Ray at work


"jason" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Access 2000
>
> I need some help interogatting a table and extracting via ASP the final
> field in a row which has a value. In other words, I have a maximum of 10
> fields but, at the user level he may he only enter values into the first
> four. I need to ALWAYS extract the final or last field that has a value.

In
> the example below this would be PriceField5 which has a value of $162,000.
>
> The user stopped at this field and left the rest blank.
>
> I considered cycling through the row and checking for null or empty

values
> but I suspect this may be very messy and have not had much success in the
> past. Is there a better more elegant way to achieve my goal?
>
> --PRICE TABLE--
> PriceField1 (eg 100,000)
> PriceField2 (eg 130,000)
> PriceField3 (eg 142,000)
> PriceField4 (eg 152,000)
> PriceField5 (eg 162,000)
> PriceField6 (empty)
> PriceField7 (empty)
> PriceField8 (empty)
> PriceField9 (empty)
> PriceField10 (empty)
>
> Many thanks in advance
>
> Jason
>
>
>
>
>
>
>



 
Reply With Quote
 
 
 
 
jason
Guest
Posts: n/a
 
      12-09-2003
Well in the past I would try checking for null values and empty values eg
len(request.form.item("PriceField1"). But, I usually end up with longwinded
code. I thought perhaps there might be away to put the entire 10 fields into
an array and they cycle through them.......when you say loop through them I
am not even sure which convention to use or

rs.getrows ?
Do until rs.eof?

I am also not sure whether I should cycle all the form elements: eg:
request.form.item(i) or just do them individually?

At the risk of sounding lazy could you possibly submit an example of how you
would do it?

Many thanks
Jason


"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#(E-Mail Removed)...
> I would think that looping would be okay for this. What are you trying to
> do or why haven't you had luck with that?
>
> Ray at work
>
>
> "jason" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Access 2000
> >
> > I need some help interogatting a table and extracting via ASP the final
> > field in a row which has a value. In other words, I have a maximum of 10
> > fields but, at the user level he may he only enter values into the first
> > four. I need to ALWAYS extract the final or last field that has a value.

> In
> > the example below this would be PriceField5 which has a value of

$162,000.
> >
> > The user stopped at this field and left the rest blank.
> >
> > I considered cycling through the row and checking for null or empty

> values
> > but I suspect this may be very messy and have not had much success in

the
> > past. Is there a better more elegant way to achieve my goal?
> >
> > --PRICE TABLE--
> > PriceField1 (eg 100,000)
> > PriceField2 (eg 130,000)
> > PriceField3 (eg 142,000)
> > PriceField4 (eg 152,000)
> > PriceField5 (eg 162,000)
> > PriceField6 (empty)
> > PriceField7 (empty)
> > PriceField8 (empty)
> > PriceField9 (empty)
> > PriceField10 (empty)
> >
> > Many thanks in advance
> >
> > Jason
> >
> >
> >
> >
> >
> >
> >

>
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      12-09-2003
Wait, are you talking about a recordset here or a form collection?

If form collection, there is no first and last. (Some would say the same
about columns in a database table as well, but that's all in how you
interpret things.)

Ray at work

"jason" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Well in the past I would try checking for null values and empty values eg
> len(request.form.item("PriceField1"). But, I usually end up with

longwinded
> code. I thought perhaps there might be away to put the entire 10 fields

into
> an array and they cycle through them.......when you say loop through them

I
> am not even sure which convention to use or
>
> rs.getrows ?
> Do until rs.eof?
>
> I am also not sure whether I should cycle all the form elements: eg:
> request.form.item(i) or just do them individually?
>
> At the risk of sounding lazy could you possibly submit an example of how

you
> would do it?
>
> Many thanks
> Jason
>
>
> "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
> news:#(E-Mail Removed)...
> > I would think that looping would be okay for this. What are you trying

to
> > do or why haven't you had luck with that?
> >
> > Ray at work
> >
> >
> > "jason" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Access 2000
> > >
> > > I need some help interogatting a table and extracting via ASP the

final
> > > field in a row which has a value. In other words, I have a maximum of

10
> > > fields but, at the user level he may he only enter values into the

first
> > > four. I need to ALWAYS extract the final or last field that has a

value.
> > In
> > > the example below this would be PriceField5 which has a value of

> $162,000.
> > >
> > > The user stopped at this field and left the rest blank.
> > >
> > > I considered cycling through the row and checking for null or empty

> > values
> > > but I suspect this may be very messy and have not had much success in

> the
> > > past. Is there a better more elegant way to achieve my goal?
> > >
> > > --PRICE TABLE--
> > > PriceField1 (eg 100,000)
> > > PriceField2 (eg 130,000)
> > > PriceField3 (eg 142,000)
> > > PriceField4 (eg 152,000)
> > > PriceField5 (eg 162,000)
> > > PriceField6 (empty)
> > > PriceField7 (empty)
> > > PriceField8 (empty)
> > > PriceField9 (empty)
> > > PriceField10 (empty)
> > >
> > > Many thanks in advance
> > >
> > > Jason
> > >
> > >
> > >
> > >
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      12-09-2003
> If form collection, there is no first and last.

That depends. You can certainly iterate through a form collection in the
same order as the form elements appeared on the page (see
http://www.aspfaq.com/2036). I don't believe this will obey optioanl
TABINDEX settings, however.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


 
Reply With Quote
 
jason
Guest
Posts: n/a
 
      12-09-2003
I'm sorry - I would be iterating the form collection on the collecting page.

But, my main problem is initially interoggating the row or record to find
the last non-empty field in a row containng a maximu of 10 fields.

Thus, fields 1-5 might containt data (ie price).

I would need to determine that field five has data and then display the
first five field values in INPUT boxes for the user to edit and then submit
to the next page.

This is the challenge for me...I am not exactly sure how to do this.

Does this make sense?

Thanks
Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#(E-Mail Removed)...
> I would think that looping would be okay for this. What are you trying to
> do or why haven't you had luck with that?
>
> Ray at work
>
>
> "jason" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Access 2000
> >
> > I need some help interogatting a table and extracting via ASP the final
> > field in a row which has a value. In other words, I have a maximum of 10
> > fields but, at the user level he may he only enter values into the first
> > four. I need to ALWAYS extract the final or last field that has a value.

> In
> > the example below this would be PriceField5 which has a value of

$162,000.
> >
> > The user stopped at this field and left the rest blank.
> >
> > I considered cycling through the row and checking for null or empty

> values
> > but I suspect this may be very messy and have not had much success in

the
> > past. Is there a better more elegant way to achieve my goal?
> >
> > --PRICE TABLE--
> > PriceField1 (eg 100,000)
> > PriceField2 (eg 130,000)
> > PriceField3 (eg 142,000)
> > PriceField4 (eg 152,000)
> > PriceField5 (eg 162,000)
> > PriceField6 (empty)
> > PriceField7 (empty)
> > PriceField8 (empty)
> > PriceField9 (empty)
> > PriceField10 (empty)
> >
> > Many thanks in advance
> >
> > Jason
> >
> >
> >
> >
> >
> >
> >

>
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      12-09-2003

"jason" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm sorry - I would be iterating the form collection on the collecting

page.
>
> But, my main problem is initially interoggating the row or record to find
> the last non-empty field in a row containng a maximu of 10 fields.
>
> Thus, fields 1-5 might containt data (ie price).
>
> I would need to determine that field five has data and then display the
> first five field values in INPUT boxes for the user to edit and then

submit
> to the next page.
>
> This is the challenge for me...I am not exactly sure how to do this.
>
> Does this make sense?



Using what Aaron posted, you can do:

Dim i
For i = Request.Form.Count To 1 Step -1
If Request.Form.Item(i) <> "" Then
Response.Write "The last item with data is " & Request.Form.Key(i)
Exit For
End If
Next

That should get you started, anyway. That will loop through the form
collection backwards and look for the ~first~ value, which will be the last,
since it's going in reverse. Note it doesn't trim values or discriminate
form field names or anything.

Ray at work


 
Reply With Quote
 
jason
Guest
Posts: n/a
 
      12-10-2003
Thank you - I did not know you could actually go in reverse.....I will take
a closer look at the aspfaq and build furhter from it...

Cheers
Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#(E-Mail Removed)...
>
> "jason" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I'm sorry - I would be iterating the form collection on the collecting

> page.
> >
> > But, my main problem is initially interoggating the row or record to

find
> > the last non-empty field in a row containng a maximu of 10 fields.
> >
> > Thus, fields 1-5 might containt data (ie price).
> >
> > I would need to determine that field five has data and then display the
> > first five field values in INPUT boxes for the user to edit and then

> submit
> > to the next page.
> >
> > This is the challenge for me...I am not exactly sure how to do this.
> >
> > Does this make sense?

>
>
> Using what Aaron posted, you can do:
>
> Dim i
> For i = Request.Form.Count To 1 Step -1
> If Request.Form.Item(i) <> "" Then
> Response.Write "The last item with data is " & Request.Form.Key(i)
> Exit For
> End If
> Next
>
> That should get you started, anyway. That will loop through the form
> collection backwards and look for the ~first~ value, which will be the

last,
> since it's going in reverse. Note it doesn't trim values or discriminate
> form field names or anything.
>
> Ray at work
>
>



 
Reply With Quote
 
jason
Guest
Posts: n/a
 
      12-10-2003
ps: This reverse form script works absolutely great....I can find so many
applications for it...thanks again to Ray and Aaron.

- Jason
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:#(E-Mail Removed)...
>
> "jason" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I'm sorry - I would be iterating the form collection on the collecting

> page.
> >
> > But, my main problem is initially interoggating the row or record to

find
> > the last non-empty field in a row containng a maximu of 10 fields.
> >
> > Thus, fields 1-5 might containt data (ie price).
> >
> > I would need to determine that field five has data and then display the
> > first five field values in INPUT boxes for the user to edit and then

> submit
> > to the next page.
> >
> > This is the challenge for me...I am not exactly sure how to do this.
> >
> > Does this make sense?

>
>
> Using what Aaron posted, you can do:
>
> Dim i
> For i = Request.Form.Count To 1 Step -1
> If Request.Form.Item(i) <> "" Then
> Response.Write "The last item with data is " & Request.Form.Key(i)
> Exit For
> End If
> Next
>
> That should get you started, anyway. That will loop through the form
> collection backwards and look for the ~first~ value, which will be the

last,
> since it's going in reverse. Note it doesn't trim values or discriminate
> form field names or anything.
>
> Ray at work
>
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      12-10-2003
You're welcome!

Ray at work

"jason" <(E-Mail Removed)> wrote in message
news:O%(E-Mail Removed)...
> ps: This reverse form script works absolutely great....I can find so many
> applications for it...thanks again to Ray and Aaron.
>
> - Jason
> "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
> news:#(E-Mail Removed)...
> >
> > "jason" <(E-Mail Removed)> wrote in message



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
Copy File Field Value to Dynamic File Field Value VUNETdotUS Javascript 25 11-10-2007 10:36 AM
extract a value from a field in a file nufin Perl Misc 3 06-29-2005 07:03 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
If value in name field in top row disable submit button until add button is pressed or field is cleared. Chuck Javascript 0 11-10-2003 02:23 AM



Advertisments