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= "
[email protected]"
sAddress= "Richard address is: "
Case "Paul"
sContact= "
[email protected]"
sAddress= "Paul address is : "
Case "James"
sContact= "
[email protected]"
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= "
[email protected]"
| >> sAddress= "my address"
| >> Case "Paul "
| >> sContact= "
[email protected]"
| >> sAddress= "my address"
| >>
| >> 'Add others copy from here
| >> Case "James Price"
| >> sContact= "
[email protected]"
| >> '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="
[email protected]">James (development manager</option>
| >> <option value="
[email protected]"<%If sSel=("
[email protected]")
| >> Then Response.Write " selected" %>>Richard </option>%>>Richard (
| >> League,Competition officer)</option>
| >> <option value="
[email protected]">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= "
[email protected]"
| >>> sAddress= ""
| >>> Case "Richard"
| >>> sContact= "
[email protected]"
| >>> 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= "
[email protected]"
| >>>> Case "Richard"
| >>>> sContact= "
[email protected]"
| >>>> 'Add others here
| >>>> Case Else
| >>>> sContact="" ' Missing form data or no match found
| >>>> Response.Redirect "SomeErrorPage.asp"
| >>>> End Select
| >>>> %>
| >>>>
| >>>>
| >>>>
| >>>>
| >>>
| >>>
| >>
| >>
| >
| >
|
|