PDA

View Full Version : Better code for drop down list


jeena
06-28-2003, 02:09 AM
I need to output a statement in a page B depending on two drop down list in page A(Meaning that only if option from the first drop down list and second drop down list is selected then a statement will be displayed on page B upon submition of form A)

I have done my code like this: -
----------------------------------------------------------------------
'read value from drop down list
Drop1=Request.Form("location")
Drop2=Request.Form("unit")

If (Drop1 = "Block A") And (Drop2 = "Sports") Then
Response.Write "Report has been sent to Mr. A"
End If

If(Drop1 = "Block B") And (Drop2="library")Then
Response.Write "Report has been sent to Mr. B"
End If
-------------------------------------------------------------------------
My question is; is there any other better method to do this.
Because if I code using this method i'm going to have to write 200 "if" statements.

Thank in advance......

oracleguy
06-28-2003, 04:40 AM
You could put all the information into database then run a SQL query against the database and it could tell you who to send it to or whatever.

The query would be pretty simple just, SELECT SendTo FROM MyTable WHERE location='" & Drop1 & "' AND unit='" & Drop2 & "'"

That should drastically reduce the ammount of code plus make it easier to manage. You could even populate the drop down boxes on the first page from the database.