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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sub routine

Status
Not open for further replies.

mot98

MIS
Jan 25, 2002
647
CA
My asp page has a list box that the user selects from, and then is supposed to go to the corresponding sub routine depending on what is selected.

The code looks like this:

Select Case fromForm
Case varSelect=" "
initForm
Case varSelect="ADD"
addForm
Case varSelect="EDIT"
editForm
Case varSelect="DELETE"
deleteForm
Case Else
initForm
End Select


The initial form looks like this:

Sub initForm
Response.Write &quot;<p>Please choose one of the following options:</p>&quot;
Response.Write &quot;<form method='get' action='ASS3P1.asp'>&quot;
Response.Write &quot;<p><SELECT NAME=varSelect SIZE=1>&quot;
Response.Write &quot;<OPTION VALUE=''></OPTION>&quot;
Response.Write &quot;<OPTION VALUE=ADD>ADD</OPTION>&quot;
Response.Write &quot;<OPTION VALUE=DELETE>DELETE</OPTION>&quot;
Response.Write &quot;<OPTION VALUE=EDIT>EDIT</OPTION>&quot;
Response.Write &quot;</SELECT></p>&quot;
Response.Write &quot;<p><input type=submit></p>&quot;
Response.Write &quot;</FORM>&quot;
End sub


I am using the &quot;get&quot; method, and am seeing it pass the varSelect variable fine. But no matter what I select ie: Add, Edit, Delete..it always comes back to the initForm??

Am I missing something here to make it go to the correct sub routine?

Thanks,


mot98..[peace]

&quot;Where's the beer?&quot;
 
Show us how you populate the variable fromForm.

You should have something like this:

fromForm = Request.form(&quot;varSelect&quot;)

'**verify you are getting the right value:
Response.write(&quot;Value is &quot; & fromForm & &quot;<br>&quot;)

Select Case fromForm
...
End Select
 
Hi Juanita..

I verified the data, and it is coming out fine..
Response.Write (&quot;Value is &quot;& fromForm &&quot;<br>&quot;)
gave me Value is ADD, when I selected add from the list box.

So it is passing the variable fine..but for some reason the
Select Case statement is not working properly??

Here is all of my code(I have only got test code for the last 2 sub routines:

<%
'
' Variable Declarations
'
dim vNewRecord
dim vEditRecord
dim vDeleteRecord
dim varSelect
dim fromForm

fromForm = Request.Querystring(&quot;fromForm&quot;)
' Response.Write (&quot;Value is &quot;&fromForm&&quot;<br>&quot;)
' Response.end

' Main Program to check what action to do
Select Case fromForm
' Case fromForm=&quot; &quot;
' initForm
Case fromForm=ADD
Call addForm
Case fromForm=EDIT
Call editForm
Case fromForm=DELETE
Call deleteForm
Case Else
Call initForm
End Select
'
'
Sub initForm
Response.Write &quot;<p>Please choose one of the following options:</p>&quot;
Response.Write &quot;<form method='get' action='ASS3P1.asp'>&quot;
Response.Write &quot;<p><SELECT NAME=fromForm SIZE=1>&quot;
Response.Write &quot;<OPTION VALUE=''></OPTION>&quot;
Response.Write &quot;<OPTION SELECTED VALUE=ADD>ADD</OPTION>&quot;
Response.Write &quot;<OPTION VALUE=DELETE>DELETE</OPTION>&quot;
Response.Write &quot;<OPTION VALUE=EDIT>EDIT</OPTION>&quot;
Response.Write &quot;</SELECT></p>&quot;
Response.Write &quot;<p><input type=submit></p>&quot;
' Response.Write &quot;<input type=hidden value=initForm name=fromForm>&quot;
Response.Write &quot;</FORM>&quot;
End sub
'
'
'

sub addForm

Response.Write &quot;<p> Please enter the following information for the new record:</p>&quot;

Response.Write &quot;<p><Form Action=ASS3P1.asp Method=post>&quot;
Response.Write &quot;<br>&quot;
Response.Write &quot;Book Code: <Input Type=text Name=varBookCode>&quot;
Response.Write &quot;<br>&quot;
Response.Write &quot;Title: <Input Type=text Name=varTitle>&quot;
Response.Write &quot;<br>&quot;
Response.Write &quot;Author: <Input Type=text Name=varAuthor>&quot;
Response.Write &quot;<br>&quot;
Response.Write &quot;Units on Hand: <Input Type=text Name=varUnits>&quot;
Response.Write &quot;<br>&quot;
Response.Write &quot;Price: <Input Type=text Name=varPrice>&quot;
Response.Write &quot;<br>&quot;
Response.Write &quot;Year Published: <Input Type=text Name=varYear>&quot;
Response.Write &quot;<br>&quot;
Response.Write &quot;<INPUT TYPE=submit Name=submit></p>&quot;
Response.Write &quot;</Form>&quot;
End sub
%>

<%
sub editForm

Response.Write &quot;<p>Testing page2</p>&quot;

End sub

sub deleteForm

Response.Write &quot;<p>Testing page3</p>&quot;

End sub
%>


Any other Tips would be great..

Thanks
mot98..[peace]

&quot;Where's the beer?&quot;
 
Still not working..I can see that varSelect is passing the data fine.

Something must be wrong with the Select Case statement, but I can't find it.

If I comment out the

Case fromForm=&quot; &quot;
initForm


then the page automatically goes to sub addForm. It does not even go to the initial list box screen??

Can someone tell me what is going on here, as I am about to blow this thing up..[cannon] [pc] mot98..[peace]

&quot;Where's the beer?&quot;
 
Well, a couple of things:

1) Try trimming the value so that there are no trailing or leading spaces:
fromForm = Trim(Request.Querystring(&quot;fromForm&quot;))

2) Make sure your case statement conforms with this pattern:

Select Case [variable]
Case [value]
...
End Select

In this syntax, there is no &quot;Case variable = value&quot;. I personally would take out the reference to your variable = a space and let it get picked up by your Case Else, since it goes to the same place anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top