If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP form, multiple items select If statement?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-04, 10:32
stahly stahly is offline
Registered User
 
Join Date: Feb 2004
Posts: 11
ASP form, multiple items select If statement?

I used the DBW to create the database editor page. the one field i made is text with a drop down, for multiple selections.i got everything working except for the the edit page on the database editor page. heres an example of some of the code on the page (that way i can explain better with what i want to do)...

<option <% if "Jim" = FP_Field(fp_rs,"Employee") then %> selected <% end if %>>Jim</option>
<option <% if "Ken" = FP_Field(fp_rs,"Employee") then %> selected <% end if %>>Ken</option>

the above code is just 2 of the 9 users that work on projects, what i can do is select multiple at anytime, but when i go to edit a certain record it wont bring up any names unless i put in OR statements, but after looking at the total number of combinations that i would have, i hope there is a way that is much shorter.

so what i am asking is: is there a way to search that particular field using the 1 of the above if statements that if it sees Jim in any combination with other names that it selects Jim on the drop down lists automatically?

thanks

adam
Reply With Quote
  #2 (permalink)  
Old 06-23-04, 11:41
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Well, if your array was a single dimension, you could use the Join() function, but that doesn't look like that will work for you. You'll probably have to make a function to check the array:
Code:
<%
Function checkArrayForEmpl(aPeople, sPerson)

  Dim iCounter

  checkArrayForEmpl = False

  If IsArray(aPeople) Then
    For iCounter = 0 To UBound(aPeople)-1
      If aPeople(iCounter,"Employee") = sPerson Then
        checkArrayForEmpl = True
        Exit For
      End If
    Next
  End If

End Function
%>

<option <% if checkArrayForEmpl(FP_Field, "Jim") then %> selected <% end if %>>Jim</option>
<option <% if checkArrayForEmpl(FP_Field, "Ken") then %> selected <% end if %>>Ken</option>
I didn't test this, so there are bound to be errors, but the idea is that you need to iterate through the array and check to see if the string matches any rows.
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On