Newbie would appreciate help :)

H

Heather

Hi

I have been struggling with this problem for days now and not really
getting anywhere. I am new to this so apologies for bad coding etc.

I have a form where the student enters his enrolment number and this
number is passed from the asp form to a SQL database. So far so good.

Now when he doesnt have an enrolment number he writes his name. Now,
I want to pass the enrolment number as 0, that bit is working ok, and
pass the name into a special field called s1.

My code is passing too much. It passes the enrolment number as 0, the
name as s1 but also sends the "click here to continue" text.

Here is a snippet of the code. I feel that I am putting in too
many/leaving out quote marks.

I would be grateful for any help.

Many thanks

Heather

dim var
dim choice
dim stname
dim stcoursecode
dim stcoursename
dim enrol
dim stdob


stdob = request.form("stdob")
enrol = request.form("enrolment")
choice = request.form("stchoice")
stname = request.form("stName")
stcoursecode = request.form("stcoursecode")
stcoursename = request.form("stcoursename")
var = request.form("stlevel")%>



<% if var = "1" then
Response.Write "<a href= ""http://perception/q/open.dll?NAME="
&Recordset1("enrolment") & "&SESSION=7234121865394181" & "s1="
&Recordset1("stName") & ">" & "Please click here to continue" & "</a>"
else

if var = "2" then
Response.Write "<a href= ""http://perception/q/open.dll?NAME="
&Recordset1("enrolment") & "&SESSION=9952819590936663" & "s1="
&Recordset1("stName") & ">" & "Please click here to continue" & "</a>"
else

if var = "3" then
Response.Write "<a href= ""http://perception/q/open.dll?NAME="
&Recordset1("enrolment") & "&SESSION=6083780287200261" & "s1="
&Recordset1("stName") & ">" & "Please click here to continue" & "</a>"


end if
end if
end if %>
</strong> </font> </p>
</form>
 
D

Dan Sikorsky

You left out the initial <% at the beginning.

You left out the '&' that delimits each parameter in the QueryString of your
<a href statements.
 
R

Ray at

You're not closing your hrefs. Do a view source, and you'll see your HTML
is like:

<A href="http://...stuff...>Click here

It should be like:

<A href="http://...stuff...">Click here

A couple of suggestions about the code.

Instead of if/then/end ifs all over, use a select case:


Select Case var
Case "1"
sSession = "7234121865394181"
Case "2"
sSession = "9952819590936663"
Case "3"
sSession = "6083780287200261"
Case Else
''this is optional
End Select

sHref = "http://perception/q/open.dll?NAME=" & Recordset("enrolment") &
"&session=" & sSession & "&s1=" & Recordset("stName")

Response.Write "<A href=""" & sHref & """>Click here to continue</A>"

Suggestion:
Don't use Recordset("name")
Use
Recordset.Fields.Item(0).Value '''where the number is the index of the
columns in your query, starting at 0

Suggestion:
Put spaces before and after your & concatenator. You'll run into troubles
with variables that start with H, otherwise (&H implies hex number to
follow).

Ray at work



Response.Write "<a href= ""http://perception/q/open.dll?NAME="
&Recordset1("enrolment") & "&SESSION=7234121865394181" & "s1="
&Recordset1("stName") & ">" & "Please click here to continue" & "</a>"
else

if var = "2" then
Response.Write "<a href= ""http://perception/q/open.dll?NAME="
&Recordset1("enrolment") & "&SESSION=9952819590936663" & "s1="
&Recordset1("stName") & ">" & "Please click here to continue" & "</a>"
else

if var = "3" then
Response.Write "<a href= ""http://perception/q/open.dll?NAME="
&Recordset1("enrolment") & "&SESSION=6083780287200261" & "s1="
&Recordset1("stName") & ">" & "Please click here to continue" & "</a>"
 
K

Kris Eiben

You haven't closed the quote enclosing the href. Plus, this has nothing
to do with your problem, but you could use elseif or select case to
eliminate the nested if statements.
 
H

Heather

Thank you for taking the trouble to respond. I have now solved my
problem with a lot of trial and error.

Many thanks

Heather
 

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top