help with case statement

P

Paul C

Hi How do I add another Dim called sAddress like the sContact to this case
statement
Thanks
Paul M

<%
Dim ContactName, sContact
ContactName = Request.Form("name")
Select Case ContactName
Case "John"
sContact= "(e-mail address removed)"
Case "Richard"
sContact= "(e-mail address removed)"
'Add others here
Case Else
sContact="" ' Missing form data or no match found
Response.Redirect "SomeErrorPage.asp"
End Select
%>
 
T

Thomas A. Rowe

<%
Dim ContactName, sContact, sAddress
ContactName = Request.Form("name")
Select Case ContactName
Case "John"
sContact= "(e-mail address removed)"
sAddress= ""
Case "Richard"
sContact= "(e-mail address removed)"
sAddress= ""
'Add others here
Case Else
sContact="" ' Missing form data or no match found
Response.Redirect "SomeErrorPage.asp"
End Select
%>

Paul,

If you use a dropdown menu like I provided, then you can avoid having to deal with any errors and
have to redirect to another page, etc. since the values passed would always be correct.

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================
 
P

Paul C

Thanks Thomas
I still have a problem
This form posts to itself
I am trying to get it to Response.write sAddress but it won't work The idea
is that a person selects an option then submits the form when the page
reloads it displayes the sAddress
The sSel is so that the selection is reselected when the page reloads as in
option Richard
Thankyou
Paul M


<%
Dim ContactName, sContact, sAddress
ContactName = Request.Form("contactname")
Select Case ContactName
Case "Richard "
sContact= "(e-mail address removed)"
sAddress= "my address"
Case "Paul "
sContact= "(e-mail address removed)"
sAddress= "my address"

'Add others copy from here
Case "James Price"
sContact= "(e-mail address removed)"
'to here and change the relevent info
'for the dropdown copy and paste the asp in the options value below into a
newly created option and change relevent info
Case Else
sContact="" ' Missing form data or no match found

End Select
%>


<% Dim sSel
sSel= Request.Form("contactname")
%>


<form action="gbwr_contactrev.asp" method="post" name="contactname"
id="contactname">
<p>
<select name="contactname" id="select">
<option value="(e-mail address removed)">James (development manager</option>
<option value="(e-mail address removed)"<%If sSel=("(e-mail address removed)")
Then Response.Write " selected" %>>Richard </option>%>>Richard (
League,Competition officer)</option>
<option value="(e-mail address removed)">Paul </option>
</select>
<input type="submit" name="Submit" value="Submit">
</p>
</form>


<p><%
' displays the address on the page
Response.write sAddress
%>
 
T

Thomas A. Rowe

I would recommend that you post to a processing page, and not reload the page, because then you also
have to handle what happens the first time a user hit the page or returns to the page, not a major
issue, but does require additional coding.

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================
 
P

Paul C

Thanks Thomas
Best wishes
Paul M
Thomas A. Rowe said:
I would recommend that you post to a processing page, and not reload the
page, because then you also have to handle what happens the first time a
user hit the page or returns to the page, not a major issue, but does
require additional coding.

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================
 
S

Stefan B Rusynko

You apparently do not understand your script or form field values
1) it is bad practice to have your form field name and form name the same
2) the Case statement is like any other variable comparison
- if your form field name is "contactname" the value returned by Request.Form("contactname") is the value in the form
(you were using email addresses for the option values in the form and but comparing it to names in the Case)


Here is what you should have
<%
Dim sContact, sAddress, sSel
sSel = Request.Form("contactname")
Select Case sSel
Case "Richard"
sContact= "(e-mail address removed)"
sAddress= "Richard address is: "
Case "Paul"
sContact= "(e-mail address removed)"
sAddress= "Paul address is : "
Case "James"
sContact= "(e-mail address removed)"
sAddress= "James address is: "
Case Else ' Missing form data or no match found
sContact=""
sAddress= ""
End Select
%>

<form action="gbwr_contactrev.asp" method="post" name="contacts" id="contactname">
<p><select name="contactname" id="select">
<option value="James" <% IF sSel="James" THEN%> selected<%END IF%>>James (development manager</option>
<option value="Richard" <%IF sSel="Richard" THEN%> selected<%END IF%>>Richard (League,Competition officer)</option>
<option value="Paul" <%IF sSel="Paul" THEN%> selected<%END IF%>>Paul </option>
</select><input type="submit" name="Submit" value="Submit"></p>
</form>

<%IF sSel<>"" THEN%>
<p>You have selected: <%=sAddress & sContact %></p>
<%ELSE%>
<p>Select a Contact above</p>
<%END IF%>

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Thanks Thomas
| Best wishes
| Paul M
| | >I would recommend that you post to a processing page, and not reload the
| >page, because then you also have to handle what happens the first time a
| >user hit the page or returns to the page, not a major issue, but does
| >require additional coding.
| >
| > --
| > ==============================================
| > Thomas A. Rowe
| > Microsoft MVP - FrontPage
| >
| > http://www.Ecom-Data.com
| > ==============================================
| >
| >
| > | >> Thanks Thomas
| >> I still have a problem
| >> This form posts to itself
| >> I am trying to get it to Response.write sAddress but it won't work The
| >> idea is that a person selects an option then submits the form when the
| >> page reloads it displayes the sAddress
| >> The sSel is so that the selection is reselected when the page reloads as
| >> in option Richard
| >> Thankyou
| >> Paul M
| >>
| >>
| >> <%
| >> Dim ContactName, sContact, sAddress
| >> ContactName = Request.Form("contactname")
| >> Select Case ContactName
| >> Case "Richard "
| >> sContact= "(e-mail address removed)"
| >> sAddress= "my address"
| >> Case "Paul "
| >> sContact= "(e-mail address removed)"
| >> sAddress= "my address"
| >>
| >> 'Add others copy from here
| >> Case "James Price"
| >> sContact= "(e-mail address removed)"
| >> 'to here and change the relevent info
| >> 'for the dropdown copy and paste the asp in the options value below into
| >> a newly created option and change relevent info
| >> Case Else
| >> sContact="" ' Missing form data or no match found
| >>
| >> End Select
| >> %>
| >>
| >>
| >> <% Dim sSel
| >> sSel= Request.Form("contactname")
| >> %>
| >>
| >>
| >> <form action="gbwr_contactrev.asp" method="post" name="contactname"
| >> id="contactname">
| >> <p>
| >> <select name="contactname" id="select">
| >> <option value="(e-mail address removed)">James (development manager</option>
| >> <option value="(e-mail address removed)"<%If sSel=("(e-mail address removed)")
| >> Then Response.Write " selected" %>>Richard </option>%>>Richard (
| >> League,Competition officer)</option>
| >> <option value="(e-mail address removed)">Paul </option>
| >> </select>
| >> <input type="submit" name="Submit" value="Submit">
| >> </p>
| >> </form>
| >>
| >>
| >> <p><%
| >> ' displays the address on the page
| >> Response.write sAddress
| >> %>
| >>
| >>
| >> | >>> <%
| >>> Dim ContactName, sContact, sAddress
| >>> ContactName = Request.Form("name")
| >>> Select Case ContactName
| >>> Case "james"
| >>> sContact= "(e-mail address removed)"
| >>> sAddress= ""
| >>> Case "Richard"
| >>> sContact= "(e-mail address removed)"
| >>> sAddress= ""
| >>> 'Add others here
| >>> Case Else
| >>> sContact="" ' Missing form data or no match found
| >>> > End Select
| >>> %>
| >>>
| >>> Paul,
| >>>
| >>> If you use a dropdown menu like I provided, then you can avoid having to
| >>> deal with any errors and have to redirect to another page, etc. since
| >>> the values passed would always be correct.
| >>>
| >>> --
| >>> ==============================================
| >>> Thomas A. Rowe
| >>> Microsoft MVP - FrontPage
| >>>
| >>> http://www.Ecom-Data.com
| >>> ==============================================
| >>>
| >>>
| >>> | >>>> Hi How do I add another Dim called sAddress like the sContact to this
| >>>> case statement
| >>>> Thanks
| >>>> Paul M
| >>>>
| >>>> <%
| >>>> Dim ContactName, sContact
| >>>> ContactName = Request.Form("name")
| >>>> Select Case ContactName
| >>>> Case "John"
| >>>> sContact= "(e-mail address removed)"
| >>>> Case "Richard"
| >>>> sContact= "(e-mail address removed)"
| >>>> 'Add others here
| >>>> Case Else
| >>>> sContact="" ' Missing form data or no match found
| >>>> Response.Redirect "SomeErrorPage.asp"
| >>>> End Select
| >>>> %>
| >>>>
| >>>>
| >>>>
| >>>>
| >>>
| >>>
| >>
| >>
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top