Click to See Complete Forum and Search --> : Complicated Form
elise
06-17-2005, 03:35 PM
Hello,
can someone help me with this:
I need to create a form, and right at the beginning the user will be asked to make a selection from 5 different options, and multiple can be selected.
If he selects 1, 3 and 4 then a form is generated.
If he selects 2 and 4 a different form is generated.
How can I do this with ASP and SQL server?
Thanks,
elise
buntine
06-17-2005, 11:10 PM
You could use a series of If Statements from your ASP script. Or you could create an array and see which indexes are populated.
This is not very elegant, but:
If Request.Form("option1") <> "" And Request.Form("option2") = "" And Request.Form("option3") <> "" And Request.Form("option4") <> "" Then
'' Generate a form. Or transfer execution to the form.
ElseIf Request.Form("option1") = "" And Request.Form("option2") <> "" And Request.Form("option3") = "" And Request.Form("option4") <> "" Then
'' Generate a different form. Or transfer execution to that form.
Else
'' Do something.
End If
Regards.
simflex
06-20-2005, 10:45 PM
Another more elegant, though complicated way is to create an access level for each form entry level.
You could then use then use the if statement that buntine talked about.
'To protect yourself, If Not objRS.EOF Then
if access_level = whatever1 then
response.redirect "first entery"
elseif access_level = whatever2 then
response.redirect = "second entery"
etc
etc
This ofcourse will work if they have to login first before proceeding.
MarkGG
06-21-2005, 08:37 AM
I need something similar to this code so I may as well ask here. So I have people fill out the forms on the previous page which is only two fields a select box and a text field. They submit. At this point I would like to generate a different form depends on which of the drop box choices they have made(Out of People, Facility, Town). So I would go about it like so?
If Request.Form("AddCategory") = "People" Then
`generate the form
Else if Request.Form("AddCategory") = "Facility" Then
`generate the form
Else if Request.Form("AddCategory") = "Town" Then
`generate the form
End if
Also, would I be generating this code by embedding HTML into JavaScript or is that VB code?
buntine
06-21-2005, 02:04 PM
Your method seems fine. Although, you do not require JavaScript to generate your form. You could create a different file for each form and then use the Server.Transfer or even Response.Redirect functions to transfer or redirect execution to the appropriate document, respectively.
Dim strURL
If Request.Form("AddCategory") = "People" Then
strURL = "peopleForm.asp"
Else if Request.Form("AddCategory") = "Facility" Then
strURL = "facilityForm.asp"
Else if Request.Form("AddCategory") = "Town" Then
strURL = "townForm.asp"
End if
Server.Transfer (strURL)
Regards.