help with asp

P

Paul C

Hi
I cant get this to work any suggestions
Thanks

<%
Dim ContactName, sContact
ContactName = Request.Form("name")
if ContactName= "Richard"
Then sContact= "(e-mail address removed)"
End if

%>
 
P

Paul C

Hi Thomas
The page will not display. there are several people with there own page I
will then have a form on there page with the caption contact joe blogs or
whatever and the form will then post to a generic contact page which will
display there name and enter there email into the recipient field of the
contact form which then posts to a send script I am trying to avoid having
several contact pages
Thanks
Paul M
 
J

Jon Spivey

Hi,
It should be like this
Dim ContactName, sContact
ContactName = Request.Form("name")
if ContactName= "Richard" Then
sContact= "(e-mail address removed)"
End if

Jon
 
T

Thomas A. Rowe

Ok, see Jon reply. If the correction he indicated doesn't work post back.

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

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

David Berry

You may also want to add in an Else there in case the contact isn't
"Richard" so you don't get a blank spot. Ex:

Dim ContactName, sContact
ContactName = Request.Form("name")
if ContactName= "Richard" Then
sContact= "(e-mail address removed)"
Else sContact = ""
End if

Then on your page, where you're writing the value you could have something
like this:

<%
If sContact <> "" Then
%>
<a href="mailto:<%=sContact%>"><%=sContact%></a>
<%Else%>
No Contact Information is Available
<% End If %>
 
S

Stefan B Rusynko

PS
Name is a reserved word in Access
- best to not to use it for any form field names if you are going to use any DB in the future
Use FirstName or FullName instead of just Name

--

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


| You may also want to add in an Else there in case the contact isn't
| "Richard" so you don't get a blank spot. Ex:
|
| Dim ContactName, sContact
| ContactName = Request.Form("name")
| if ContactName= "Richard" Then
| sContact= "(e-mail address removed)"
| Else sContact = ""
| End if
|
| Then on your page, where you're writing the value you could have something
| like this:
|
| <%
| If sContact <> "" Then
| %>
| <a href="mailto:<%=sContact%>"><%=sContact%></a>
| <%Else%>
| No Contact Information is Available
| <% End If %>
|
|
| | > Hi,
| > It should be like this
| > Dim ContactName, sContact
| > ContactName = Request.Form("name")
| > if ContactName= "Richard" Then
| > sContact= "(e-mail address removed)"
| > End if
| >
| > Jon
| >
| > | >> Hi
| >> I cant get this to work any suggestions
| >> Thanks
| >>
| >> <%
| >> Dim ContactName, sContact
| >> ContactName = Request.Form("name")
| >> if ContactName= "Richard"
| >> Then sContact= "(e-mail address removed)"
| >> End if
| >>
| >> %>
| >>
| >
| >
|
|
 
D

David Berry

You shouldn't use it as an Access Field name but you can name the Form field
anything you want. It won't affect the database at all
 
P

Paul C

Thanks everyone
If I wanted to add another recipient is it done like this

Dim ContactName, sContact
ContactName = Request.Form("name")
if ContactName= "John" Then
sContact= "(e-mail address removed)"
if ContactName= "Richard" Then
sContact= "(e-mail address removed)"

Else sContact = ""
End if


Best wishes
Paul M
 
S

Stefan B Rusynko

Agree the form field can be named anything,
- but if you use the DBRW it will use those form field names and cause errors
(and it becomes too easy to forget it is a reserved name in the future and try to map it to a DB later)

--

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


| You shouldn't use it as an Access Field name but you can name the Form field
| anything you want. It won't affect the database at all
|
|
| | > PS
| > Name is a reserved word in Access
| > - best to not to use it for any form field names if you are going to use
| > any DB in the future
| > Use FirstName or FullName instead of just Name
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > _____________________________________________
| >
| >
| > | > | You may also want to add in an Else there in case the contact isn't
| > | "Richard" so you don't get a blank spot. Ex:
| > |
| > | Dim ContactName, sContact
| > | ContactName = Request.Form("name")
| > | if ContactName= "Richard" Then
| > | sContact= "(e-mail address removed)"
| > | Else sContact = ""
| > | End if
| > |
| > | Then on your page, where you're writing the value you could have
| > something
| > | like this:
| > |
| > | <%
| > | If sContact <> "" Then
| > | %>
| > | <a href="mailto:<%=sContact%>"><%=sContact%></a>
| > | <%Else%>
| > | No Contact Information is Available
| > | <% End If %>
| > |
| > |
| > | | > | > Hi,
| > | > It should be like this
| > | > Dim ContactName, sContact
| > | > ContactName = Request.Form("name")
| > | > if ContactName= "Richard" Then
| > | > sContact= "(e-mail address removed)"
| > | > End if
| > | >
| > | > Jon
| > | >
| > | > | > | >> Hi
| > | >> I cant get this to work any suggestions
| > | >> Thanks
| > | >>
| > | >> <%
| > | >> Dim ContactName, sContact
| > | >> ContactName = Request.Form("name")
| > | >> if ContactName= "Richard"
| > | >> Then sContact= "(e-mail address removed)"
| > | >> End if
| > | >>
| > | >> %>
| > | >>
| > | >
| > | >
| > |
| > |
| >
| >
|
|
 
P

Paul C

HI
I can also do this by using a query string instead of a form to post to
this page, which would you recomend?
When I use the query string method spaces in the query string are replace
with a %20 like
%20Lane,%20Shiregreen but it displayes alright in IE would this be a problem
in other browsers?
Thankyou
Paul M
 
S

Stefan B Rusynko

You could add a bunch of If statements (for each user) or it would be better to use a Case statement

<%
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
%>

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


| Thanks everyone
| If I wanted to add another recipient is it done like this
|
| Dim ContactName, sContact
| ContactName = Request.Form("name")
| if ContactName= "John" Then
| sContact= "(e-mail address removed)"
| if ContactName= "Richard" Then
| sContact= "(e-mail address removed)"
|
| Else sContact = ""
| End if
|
|
| Best wishes
| Paul M
|
| | > You may also want to add in an Else there in case the contact isn't
| > "Richard" so you don't get a blank spot. Ex:
| >
| > Dim ContactName, sContact
| > ContactName = Request.Form("name")
| > if ContactName= "Richard" Then
| > sContact= "(e-mail address removed)"
| > Else sContact = ""
| > End if
| >
| > Then on your page, where you're writing the value you could have something
| > like this:
| >
| > <%
| > If sContact <> "" Then
| > %>
| > <a href="mailto:<%=sContact%>"><%=sContact%></a>
| > <%Else%>
| > No Contact Information is Available
| > <% End If %>
| >
| >
| > | >> Hi,
| >> It should be like this
| >> Dim ContactName, sContact
| >> ContactName = Request.Form("name")
| >> if ContactName= "Richard" Then
| >> sContact= "(e-mail address removed)"
| >> End if
| >>
| >> Jon
| >>
| >> | >>> Hi
| >>> I cant get this to work any suggestions
| >>> Thanks
| >>>
| >>> <%
| >>> Dim ContactName, sContact
| >>> ContactName = Request.Form("name")
| >>> if ContactName= "Richard"
| >>> Then sContact= "(e-mail address removed)"
| >>> End if
| >>>
| >>> %>
| >>>
| >>
| >>
| >
| >
|
|
 
B

Bob Lehmann

you can name the Form field anything you want.

Unless JavaScript is used, say for form validation, then element naming has
to be taken into consideration.

In that case, name would not be a good choice.

Bob Lehmann

David Berry said:
You shouldn't use it as an Access Field name but you can name the Form field
anything you want. It won't affect the database at all


Stefan B Rusynko said:
PS
Name is a reserved word in Access
- best to not to use it for any form field names if you are going to use
any DB in the future
Use FirstName or FullName instead of just Name

--

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


| You may also want to add in an Else there in case the contact isn't
| "Richard" so you don't get a blank spot. Ex:
|
| Dim ContactName, sContact
| ContactName = Request.Form("name")
| if ContactName= "Richard" Then
| sContact= "(e-mail address removed)"
| Else sContact = ""
| End if
|
| Then on your page, where you're writing the value you could have
something
| like this:
|
| <%
| If sContact <> "" Then
| %>
| <a href="mailto:<%=sContact%>"><%=sContact%></a>
| <%Else%>
| No Contact Information is Available
| <% End If %>
|
|
| | > Hi,
| > It should be like this
| > Dim ContactName, sContact
| > ContactName = Request.Form("name")
| > if ContactName= "Richard" Then
| > sContact= "(e-mail address removed)"
| > End if
| >
| > Jon
| >
| > | >> Hi
| >> I cant get this to work any suggestions
| >> Thanks
| >>
| >> <%
| >> Dim ContactName, sContact
| >> ContactName = Request.Form("name")
| >> if ContactName= "Richard"
| >> Then sContact= "(e-mail address removed)"
| >> End if
| >>
| >> %>
| >>
| >
| >
|
|
 
P

Paul C

Thanks Jon
What I was planning on doing was to have several a hyperlinks of contact
names on a page which send a query string with the name and address to the
contact page. this will will then be displayed as in the case of the address
or turned onto an email address and entered into a form field the form will
then be processed by a sendmail.asp
I was told somewhere that it is not good to have multiple forms on one page
so I thought hyperlinks. Is this correct ? if not how do you put more than
one form on a webpage.
Thankyou
Paul M
 
T

Thomas A. Rowe

Why not create a drop down list of names

Form:

<select size="1">
<option selected value=" ">Select Contact</option>
<option value="1">Richard Smith</option>
<option value="2">Bob Smith</option>
</select>

Process Page:

<%
If ContactName = "1" Then
sContact= "(e-mail address removed)"
ElseIf ContactName = "2" Then
sContact= "(e-mail address removed)"
End If
%>
--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

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

Paul C

Thanks Thomas
Paul M
Thomas A. Rowe said:
Why not create a drop down list of names

Form:

<select size="1">
<option selected value=" ">Select Contact</option>
<option value="1">Richard Smith</option>
<option value="2">Bob Smith</option>
</select>

Process Page:

<%
If ContactName = "1" Then
sContact= "(e-mail address removed)"
ElseIf ContactName = "2" Then
sContact= "(e-mail address removed)"
End If
%>
--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

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

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