Newbie would appreciate help :)

Discussion in 'ASP General' started by Heather, Aug 14, 2003.

  1. Heather

    Heather Guest

    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>
    Heather, Aug 14, 2003
    #1
    1. Advertising

  2. Heather

    Dan Sikorsky Guest

    You left out the initial <% at the beginning.

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

    --
    Thank you,

    Dan Sikorsky MSCS, BSCE, BAB


    "Heather" <> wrote in message
    news:...
    > 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>
    Dan Sikorsky, Aug 14, 2003
    #2
    1. Advertising

  3. Heather

    Ray at Guest

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


    "Heather" <> wrote in message
    news:...
    > 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>
    Ray at, Aug 14, 2003
    #3
  4. Heather

    Kris Eiben Guest

    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.

    "Heather" <> wrote in message
    news:...
    > 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>
    Kris Eiben, Aug 14, 2003
    #4
  5. Heather

    Heather Guest

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

    Many thanks

    Heather
    Heather, Aug 18, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shapper
    Replies:
    3
    Views:
    413
    willow
    Jun 10, 2005
  2. Tom
    Replies:
    3
    Views:
    2,494
  3. VinnyH
    Replies:
    2
    Views:
    464
    VinnyH
    Nov 22, 2003
  4. Mark Watson
    Replies:
    3
    Views:
    424
    Roger Lindsjö
    Oct 6, 2008
  5. Replies:
    4
    Views:
    119
Loading...

Share This Page