无法发布"价值"从单选按钮到表格

时间:2012-02-22 17:07:00

标签: sql-server-2008 asp-classic

创建了一个使用单选按钮的表单,但我无法将该值发布到 SponsorRegistration 表。

表格的5列名为早餐午餐晚餐晚餐甜点

当客户选择早餐并单击提交时,应在特定列下张贴“是”(是),但对我来说情况并非如此。

SponsorAmount 表包含每餐的赞助金额。我认为这些单选按钮应该有一个“if”和“elseif”语句,但我不知道如何合并以使其工作。

HTML

''''BUILD RECORDSET CONNECTION STATIC
Set OnAmount = Server.CreateObject("ADODB.Recordset")
SQLStrAmount = "SELECT * FROM SponsorAmount"
OnAmount.Open SQLStrAmount, Connect, adOpenStatic

breakfastValue = OnAmount("Breakfast")
lunchValue = OnAmount("Lunch")
goldValue = OnAmount("Gold")
diamondValue = OnAmount("Diamond")
platinumValue = OnAmount("Platinum")

''''CLOSE RECORDSET CONNECTION
OnAmount.Close
Set OnAmount = nothing

    <form method="post" action="SponsorPost.asp" onSubmit="return submitIt(this)">
        <input type="radio" name="sponsorlevelValue" value='breakfastValue' checked='checked'><b>Breakfast</b>

        <input type="radio" name="sponsorlevelValue" value='lunchValue' checked='checked'><b>Lunch</b>

        <input type="radio" name="sponsorlevelValue" value='dinnerValue' checked='checked'><b>Dinner</b>

        <input type="radio" name="sponsorlevelValue" value='supperValue' checked='checked'><b>Supper</b>

        <input type="radio" name="sponsorlevelValue" value='dessertValue' checked='checked'><b>Dessert</b>

    </form>

这是“ SponsorPost.asp ”页面。除 sponsorlevelValue 外,所有其他值都存储在数据库中。

<%
peopleVal = Request("peopleValue")
meetingVal = Request("meetingValue")
sponsorlevelVal = Request("sponsorlevelValue")
paymentTypeVal = Request("paymentTypeValue")
giftVal = Request("giftValue")
itemVal = Request("itemValue")

''''BUILD DATABASE CONNECTION
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "Provider=SQLOLEDB; Data Source=XXXXXX; Initial Catalog=XXX; User ID=XXX; Password=XXX"

''''BUILD RECORDSET CONNECTION STATIC
Set OnRS = Server.CreateObject("ADODB.Recordset")
SQLStr = "SELECT * FROM SponsorRegistration WHERE Deleted='N'"
OnRS.Open SQLStr, Connect,  adOpenDynamic, adLockOptimistic

OnRS.AddNew
OnRS("PeopleIDNum") = CLng(peopleVal)
OnRS("MeetingIDNum") = CLng(meetingVal)
OnRS("RegistrationDate") = tDate
OnRS("PaymentTypeIDNum") = CLng(paymentTypeVal)
OnRS("Gift") = giftVal
OnRS("Item") = itemVal
OnRS("Paid") = "N"
OnRS("Deleted") = "N"
OnRS.Update

''''CLOSE RECORDSET CONNECTION
OnRS.Close
Set OnRS = nothing

''''CLOSE DATABASE CONNECTION
Connect.Close
Set Connect = nothing
%>

2 个答案:

答案 0 :(得分:0)

首先,删除所有单选按钮上的checked属性。

然后检查执行此操作时看到的值

Response.write request("sponsorlevelValue")

你应该看到像

这样的东西
dinnerValue

验证完毕后,我们就可以继续下一步了。其余的将变得简单。

但您必须先从html中删除“已检查”字样。

答案 1 :(得分:0)

'On SponsorPost.asp, plug this code right before the OnRS.Update

select case true
case sponsorlevelVal = "breakfastValue"
    OnRS("Breakfast") = "Y"
case sponsorlevelVal = "lunchValue"
    OnRS("Lunch") = "Y"
case sponsorlevelVal = "dinnerValue"
    OnRS("Gold") = "Y"
case sponsorlevelVal = "supperValue"
    OnRS("Diamond") = "Y"
case sponsorlevelVal = "dessertValue"
    OnRS("Platinum") = "Y"
case else
    response.write "sponsorlevelVal has not been passed. warn the user"
    response.end
end select