Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2004, 01:37 AM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use of a Form in a Select Case scenario

I'm trying to use a Select Case scenario to change the text displayed on a subsequent page depending upon a user's choice from a series of 3 radio buttons. One of the options (C) involves using passing some data to PayPal for payment by credit card.

If I remove the "<form action="https://www.paypal.com/..." section from the case, it works fine. It doesn't like it if I leave it in and keeps giving me the message

Microsoft VBScript compilation error '800a0400'

Expected statement

/events/eventsubmitA.asp, line 108

<form action="https://www.paypal.com/



The framework of the code is below. What am I not doing right?

<%
Select Case (varType)
    Case "A"
    Response.Write"<p>Blah Blah Blah</p>"

    Case "B"
    Response.Write"More Blah"

    Case "C"
    Response.Write"Oh no, not more Blah"
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
         <input type="hidden" name="cmd" value="_xclick">
          <input type="hidden" name="business" value="[email protected]">
          <input type="hidden" name="item_name" value="<%=Request("Field")%>">
          <input type="hidden" name="amount" value="<%=strTotal%>">
      <p>
      <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
      </p>
    </form>
%>

 
Old October 19th, 2004, 12:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you post the code from /events/eventsubmitA.asp, line 108. Also it would be better if you could post the entire select case contruct. Also confirm if you have closed the SELECT CASE construct properly.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 19th, 2004, 12:55 PM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's the code as it stands at the moment. IT says there is something wron on Line 81 - where the <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> line is.

<% @LANGUAGE="VBScript" %>
<% Option Explicit %>

<%
    'Declare variables
    Dim strSpots
    Dim strCost
    Dim strTotal
    Dim SQL
    Dim varPaymentType

    strSpots = Request.Form("Tickets")
    strCost = Request.Form("Ecost")
    varPaymentType = Request.Form("PaymentType")

    'Multiply number of tickets by cost per ticket
    strTotal = strSpots * strCost

    'Open database connection
    Call OpenDB()

    'Build SQL Statement
    SQL = "INSERT INTO Eventreg (EventID, FirstName, LastName, Email, Address1, Address2, City, State, Zip, Phone, ENumber, PaymentType) VALUES ("
    SQL = SQL & Request.Form("EventID") & ", '"
    SQL = SQL & Request.Form("FirstName") & "', '"
    SQL = SQL & Request.Form("LastName") & "', '"
    SQL = SQL & Request.Form("Email") & "', '"
    SQL = SQL & Request.Form("Street1") & "', '"
    SQL = SQL & Request.Form("Street2") & "', '"
    SQL = SQL & Request.Form("City") & "', '"
    SQL = SQL & Request.Form("State") & "', '"
    SQL = SQL & Request.Form("Zip") & "', '"
    SQL = SQL & Request.Form("Phone") & "', '"
    SQL = SQL & Request.Form("Tickets") & "', '"
    SQL = SQL & Request.Form("PaymentType") & "')"

    'Execute SQL Statement to enter record into the database
    Set RS = dbConn.Execute(SQL)

%>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Event Submit</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>

<body class="body" link="#FFFFFF" vlink="#FFFFFF" style="color: #FFFFFF" bgcolor="#000080">

<h3>Event Registration Submission</h3>



<p><b>Thank you <%=Request("FirstName") & " " & Request("LastName")%> for
registering for the following event:</b></p>

<p><b><%=Request("EName")%></b></p>

<p><b>The total cost for your tickets is $<%=strTotal%>.</b></p

<%


Select Case (varPaymentType)

    Case "Check"
    Response.Write"<p>You have chosen to pay by check.</p>"


    Case "Cash"
    Response.Write"You have chosen to pay by cash. <br>"

    Case "PayPal"
    Response.Write"You have chosen to pay by credit card. Please click on the link below to pay securely via PayPal."

    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
         <input type="hidden" name="cmd" value="_xclick">
          <input type="hidden" name="business" value="[email protected]">
          <input type="hidden" name="item_name" value="<%=Request("EName")%>">
          <input type="hidden" name="amount" value="<%=strTotal%>">
      <p>
      <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
      </p>
    </form>

End Select
%>

<p>If you have any questions, please contact us.</p>



</body>

</html>
<%
    'Close and destroy connections
    Set RS = Nothing
    Call CloseDB()
%>

 
Old October 19th, 2004, 01:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

That is becasue you haven't closed the ASP tag inbetween within the third case before usage of <FORM> tags... Which is HTML code and that shouldn't be used within ASP tags.
Code:
    Case "PayPal"
    Response.Write"You have chosen to pay by credit card. Please click on the link below to pay securely via PayPal."
%>

    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
         <input type="hidden" name="cmd" value="_xclick">
          <input type="hidden" name="business" value="[email protected]">
          <input type="hidden" name="item_name" value="<%=Request("EName")%>">
          <input type="hidden" name="amount" value="<%=strTotal%>">
      <p>
      <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc.gif" border="0" name="submit" alt="Make payments 

with PayPal - it's fast, free and secure!">
      </p>
    </form>
<%
End Select
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 19th, 2004, 02:54 PM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Vijay, that's the issue though. I want to be able to use the form as part of the third case. If they check the radio button to say they want to pay by credit card, I need the PayPal button to appear. If they are payingby cash or check they don't need to see the PayPal button.

 
Old October 19th, 2004, 03:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

So do you still have problem with the CASE statements? It works fine for me here. Also just noticed that you haven't closed the PARA TAG properly in the following code. That may be causing irregularities in your code.
Code:
<p><b>The total cost for your tickets is $<%=strTotal%>.</b></p>
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 19th, 2004, 04:38 PM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess my question is: Can you have the <form... > inside the Select Case statement? If I move it outside the Select Case statement all works fine. But them I have the form active even when they have chosen "cash" or "check" (the other cases).

 
Old October 19th, 2004, 05:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, you can have the form within the case statements, so that only the form that corresponds to the case that is true is visible.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 19th, 2004, 07:16 PM
Registered User
 
Join Date: Oct 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yahoo! Could you please give me an idea on the syntax as I suspect that is my issue>

Cheers,

Jon

 
Old October 20th, 2004, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Jon,

May be I lost focus on this. Can you explain what you are looking for. As I see it working fine with the usage of FORM within the SELECT CASE construct. I see relevant behaviour based on the option selected. I see the PAYPAL image only when the Option selected is "PayPal".

Could you explain what the issue you are facing, so as to help you better.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using IS in Select Case mega Pro VB 6 4 August 22nd, 2005 08:40 AM
Select Case junaidraja30 Access VBA 1 February 5th, 2005 08:30 PM
select case yuvalk SQL Server 2000 4 August 25th, 2004 02:33 PM
Select Case morpheus VB How-To 1 August 13th, 2003 09:14 AM
Select Case andy24 Classic ASP Databases 5 July 25th, 2003 07:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.