如何在表单的多项选择中返回适当的值?

时间:2013-11-30 01:52:02

标签: html vbscript asp-classic contact-form

我正在建立一个反馈页面,要求用户选择他们对培训的感受。他们可以将服务评为“优秀”,“好”或“差”。我已经看到了一些类似的问题,只有在检查了某些内容时才会解决,在这种情况下,据说它声明了一个显式值。我想这可以用于“是”的回应。但是当你有多种选择时呢?

不确定我的VB脚本在哪里出错。

寄件人/ training_feedback_send.asp

<html>
<head>
<%
Sub ProcessContact
  Response.Buffer = true    
  dim gRating, gTrainerKnowledgeable, gNotKnowl, gTrainingExperience, gTrainingMaterials, gRateUI, gTs150Perform, gTs150NonPerformReason, gRestorationsAttempted, gRestorationsSuccessful, gRestorationsUnsuccessful, gFeatureChange, gFutureUpdates, gPurchasingMotivation, gAdditionalQuestions, gContactRequest, gFullName, gEmail

  gRating = Request.Form("Rating")
  gTrainerKnowledgeable = Request.Form("TrainerKnowledgeable")
  gNotKnowl = Request.Form("gNotKnowl")
  gTrainingExperience = Request.Form("TrainingExperience")
  gTrainingMaterials = Request.Form("TrainingMaterials")    
  gRateUI = Request.Form("RateUI")
  gTs150Perform = Request.Form("Ts150Perform")
  gTs150NonPerformReason = Request.Form("Ts150Perform")
  gRestorationsAttempted = Request.Form("RestorationsAttempted")
  gRestorationsSuccessful = Request.Form("RestorationsSuccessful")
  gRestorationsUnsuccessful = Request.Form("RestorationsUnsuccessful")  
  gFeatureChange = Request.Form("FeatureChange")
  gFutureUpdates = Request.Form("FutureUpdates")
  gPurchasingMotivation = Request.Form("PurchasingMotivation")
  gAdditionalQuestions = Request.Form("AdditionalQuestions")
  gContactRequest = Request.Form("ContactRequest")

  gFullName = Request.Form("FullName")
  gEmailAddress = Request.Form("EmailAddress")


  msg = msg & "How would you rate the overall effectiveness of the on-site training?: " & gRating & chr(10)& chr(13)

  msg = msg & "Did you feel that the trainer was knowledgeable on the product and answered your questions to your satisfaction? If not, explain why: " & gTrainerKnowledgeable & chr(10)& chr(13)

  msg = msg & "Did you feel that the trainer was knowledgeable on the product and answered your questions to your satisfaction? If not, explain why: " & gNotKnowl & chr(10)& chr(13)

  msg = msg & "How would you rate your training experience on a scale of 1 - 5, where 1 is poor and 5 is excellent?: " & gTrainingExperience & chr(10)& chr(13)

  msg = msg & "Do you find the published training materials helpful?(quickstart guide, tutorials, etc.): " & gTrainingMaterials & chr(10)& chr(13)

  msg = msg & "How would you rate the user interface (GUI) in terms of ease of use and clarity of information?: " & gRateUI& chr(10)& chr(13)

  msg = msg & "Does the TS-150 perform as you anticipated? " & gTs150Perform & chr(10)& chr(13) 

  msg = msg & "If not, in what way is the performance different?: " & gTs150NonPerformReason & chr(10)& chr(13) 

  msg = msg & "How many restorations have you attempted?: " & gRestorationsAttempted & chr(10)& chr(13)

  msg = msg & "How many were successful?: " & gRestorationsSuccessful & chr(10)& chr(13)

  msg = msg & "Please describe the problems on any unsuccessful restorations. For example, did they fail to mill? Did they not seat well? Were there problems with the material?: " & gRestorationsUnsuccessful & chr(10)& chr(13)

  msg = msg & "Are there any features of the TS150 that you would change? If so what would they be?: " & gFeatureChange & chr(10)& chr(13)

  msg = msg & "What features would you like to see in future updates to the design software and mill software?: " & gFutureUpdates & chr(10)& chr(13)

  msg = msg & "What was your primary motivation for purchasing IOS products?: " & gPurchasingMotivation & chr(10)& chr(13)

  msg = msg & "Do you have additional questions or would you like additional training?: " & gAdditionalQuestions & chr(10)& chr(13)

  msg = msg & "Would you like to be contacted as a follow-up to this survey?: " & gContactRequest & chr(10)& chr(13)

  msg = msg & "Full Name: " & gFullName & chr(10)& chr(13)
  msg = msg & "Email Address: " & gEmailAddress & chr(10)& chr(13)

信息页/训练feedback.aspx

<form action="/mailers/training_feedback_send.asp" method="post" name="Form1" id="trainingFeedback">
  <fieldset>
      <legend>Training and Product Feedback</legend>

        <div class="row">

          <div class="twelve columns">
            <label>How would you rate the overall effectiveness of the on-site training?</label>
            <input type="radio" name="Rating" value="Excellent">Excellent<br>
            <input type="radio" name="Rating" value="Good">Good<br>
            <input type="radio" name="Rating" value="Poor">Poor<br>
          </div>

          <div class="twelve columns">
            <label>Did you feel that the trainer was knowledgeable on the product and answered your questions to your satisfaction? 
            <br>If not, explain why.</label>
            <input type="radio" name="TrainerKnowledgeable" value="yes"><span>Yes</span>
            <input type="radio" name="TrainerKnowledgeable" value="no"><span>No</span>
            <textarea id="gNotKnowl" name="gNotKnowl" class="twoLines" rows="2" placeholder="reason"></textarea>
          </div>

2 个答案:

答案 0 :(得分:2)

不使用<input type="checkbox">,而是使用Radio Button输入类型:

<input type="radio" name="Rating" value="Excellent" checked>Excellent<br>
<input type="radio" name="Rating" value="Good">Good<br>
<input type="radio" name="Rating" value="Poor">Poor<br>

修改:我添加了checked属性。从以上链接:

  

某些浏览器需要在组中选择一个单选按钮   一直。为确保做出适当的默认选择,   作者可能希望将一个无线电 INPUT 元素定义为   的检查。

答案 1 :(得分:0)

我的原始问题存在多个问题。由于有多个选项可供选择,一次只能进行一次选择,因此有必要将<input type="checkbox"更改为<input type="radio"。有必要声明一个值,我给每个选项id(虽然可能没有必要)。这是成功通过的内容

信息页/训练feedback.aspx

<input type="radio" name="Rating" id="RatingE" value="Excellent">Excellent<br>
<input type="radio" name="Rating" id="RatingG" value="Good">Good<br>
<input type="radio" name="Rating" id="RatingP" value="Poor">Poor<br>


在我的.asp文件中,我添加了以下内容

<强>寄件人/ training_feedback_send.asp

dim gRating

gRating = Request.Form("Rating")

msg = msg & "How would you rate the overall effectiveness of the on-site training?: " & gRating & chr(10)& chr(13)


这是我在电子邮件中收到的内容

enter image description here


以上内容应该解决任何尝试过类似事情的人。但应该注意的是,关于我收到的“服务器错误”。这是因为我在.asp文件中为接收电子邮件声明了变量。在对变量进行硬编码后,没有问题。

objCDO.From = "email@example.com"

这就是现在“from”字段中显示的内容。您可以根据需要设置自己的电子邮件。但我建议使用像feedback@yoursite.com

这样的描述性名称

在我的硬编码电子邮件之上,我添加了以下内容

msg = msg & "Email Address: " & gEmailAddress & chr(10)& chr(13)

因为我的表单收集了来自该网站访问者的电子邮件。同样,你可能想要这样做。我之前犯过错误

objCDO.From = gEmailAddress

如果该字段为空,则会导致错误。如果您有表单验证,那可能不是问题。但在我们的案例中,项目经理希望所有字段都是完全可选的。