获取输出到电子邮件的收音机/复选框的值?

时间:2017-03-14 22:26:23

标签: coldfusion

继承我的代码:

<cfparam name='form.firstName' Default=''>
<cfparam name='form.yes' Default=''>
<cfparam name='form.no' Default=''>
<cfparam name='form.clean' Default=''>
<cfparam name='form.light' Default=''>
<cfparam name='form.heavy' Default=''>
<cfparam name='form.superheavy' Default=''>

<label for="firstName">Guest Access:</label>
<input type="textbox" name="firstName" value="#form.firstName#">

<label for="allkeysaccountedfor">All keys are accounted for?:</label>
<select>
  <option value="#form.yes#" name="yes">Yes</option>
  <option value="#form.no#" name="no">No</option>
</select>

<label for="unitcondition">Unit Condition?:</label>
  <input type="radio" name="clean" value="#form.clean#"><span>Clean</span>
  <input type="radio" name="light" value="#form.light#"><span>Light</span>
  <input type="radio" name="heavy" value="#form.heavy#"><span>Heavy</span>
  <input type="radio" name="superheavy" value="#form.superheavy#"><span>SuperHeavy</span>

当我提交表单时,我收到一封电子邮件,返回我放入文本框的内容,但是当我选中是或否或选择单选按钮的选项时,电子邮件中不会返回任何内容。非常感谢任何建议,谢谢!

1 个答案:

答案 0 :(得分:0)

您在选择和单选按钮的选项中设置了名称属性。我会尝试将它设置为父元素,如下所示:

<cfparam name='form.firstName' default=''>
<cfparam name='form.allkeysaccountedfor' default=''>
<cfparam name='form.unitcondition' default=''>

<label for="firstName">Guest Access:</label>
<input type="textbox" id="firstName" name="firstName" value="#form.firstName#">

<label for="allkeysaccountedfor">All keys are accounted for?:</label>
<select name="allkeysaccountedfor" id="allkeysaccountedfor">
    <option value="yes" <cfif allkeysaccountedfor eq "yes">selected</cfif>>Yes</option>
    <option value="no" [[do the same for no here]] >No</option>
</select>

<label for="unitcondition" id="unitcondition">Unit Condition?:</label>
<input type="radio" name="unitcondition" value="clean" <cfif unitcondition eq "clean">checked</cfif>><span>Clean</span>
<input type="radio" name="unitcondition" value="light" [[do the same for this value]] ><span>Light</span>
<input type="radio" name="unitcondition" value="heavy" [[do the same for this value]] ><span>Heavy</span>
<input type="radio" name="unitcondition" value="superheavy" [[do the same for this value]] ><span>SuperHeavy</span>

然后,在您的电子邮件中,我会查找上面的3个表单变量。另请注意,我在您的HTML元素中添加了“id”。这是因为标签中的“for”属性指定了标签绑定到哪个表单元素,并使用“id”属性来执行此操作。