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!

I want to skip a form item 1

Status
Not open for further replies.

AlaskanDad

Programmer
Mar 1, 2002
188
US
I'm trying to update my recordset using a for next loop but want to skip the first dropdown box because it is only being used for navigation.

Here is a synopsis of my current code:

If request.form ("SaveButton") = "Save Changes" Then
For x = 1 to request.form.count
If request.form (x) <> &quot;Save Changes&quot; Then
myRS.Fields(x) = request.form(x)
End If
Next
End If

This cycles through all of the values sent from the form and skips over the Submit button because the value is &quot;Save Changes&quot;.

The first form item is a dropdown box
Name: ContactSelect
Value: Some value between 1 and 1000

How do I get the If Then statement to also skip the ContactSelect box?

Thanks in advance,
Rob


 
When you set your loop to cycle through all your fields, why not just start the increment number one higher. That way it will skip that form field.

Roj
 
Good point. I should have brought it up before. I am using this as a generic saving function for different pages. On some of the pages, I will want to begin with the first form item. However, on this page, I want to start with the second one.

... pauses to think ...

Wait! If I send a variable StartWith = 2 for this page and use StartWith = 1 for the others it could work if my For statement is:

For a = StartWith to request.form.count

Thanks for jogging my brain!
 
You know, if you do a

Code:
for each item in Request.Form
 if item <> &quot;SkipThisElement&quot; and
    item <> &quot;SkipAnotherElement&quot; then

 'do something with the form
  Response.write Request.Form(item)
 end if
next

This is probably a little bit more scalable... leo

------------
Leo Mendoza
lmendoza@garbersoft.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top