不从复选框拾取表单值 [英] not picking up form values from checkbox
问题描述
我在Cold Fusion中有一个表单,其中包含一组复选框。我正在将此表单提交到页面frag5.cfm。 frag5.cfm中只有一行代码。
I have a form in Cold Fusion which contains a set of checkboxes. I am submitting this form to the page frag5.cfm. There is only one line of code in frag5.cfm.
<cfoutput>values are #form.f1# </cfoutput>
此行显示values are - 即复选框的表单值,名称f1未被拾取。
This line shows "values are " -- that is, the form values for the checkboxes, all with name f1 are not being picked up.
这是错误的方法来获取这些值吗?有人能告诉我正确的事吗?原始格式如下:
Is this the wrong way to pick up these values? Could someone tell me the right thing to do? The original form is below:
<form name = "fields"
action = "frag5.cfm"
method = "post"
onkeypress = "return event.keyCode != 13;">
<table style = "margin-left:165px" >
<caption style = "padding-top: 20px" >Restrict Report To: </caption>
<tr>
<td>Master Event:</td>
<td><input type = "checkbox"
id = "cb_e"
name = "f1"
value = ""
onclick = ischecked("cb_e","hid_e")
class = "check1">
<label for = "cb_e"> </label>
<input type = "hidden" name = "finsel" id = "hid_e" value = "unchecked">
</td>
<td style = "width: 25px"> </td>
<td>SubEvent:</td>
<td><input type = "checkbox"
id = "cb_s"
value = ""
name = "f1"
onclick = ischecked("cb_s","hid_s")
class = "check1" >
<label for = "cb_s"> </label></td>
<input type = "hidden" name = "finsel" id = "hid_s" value = "unchecked">
</td>
</tr>
</table>
<table style ="margin-left: 175px; margin-top: 20px;" >
<td style = "width: 150px;" id = "chuprep" class = ixes2">
</td>
<td style = "width: 150px;">
<input type = "Submit"
name ="Submitfin1"
class = "submitbut"
value = "Submit" >
</td>
</tr>
</table>
</form>
ischecked is:
The code for ischecked is :
function ischecked(id, passid) {
//alert("got to ischecked" + id + passid);
var ischeck = document.getElementById(id).checked;
if(ischeck){
document.getElementById(passid).value = "checked";}
else {
document.getElementById(passid).value = "unchecked";}
}//end function ischeck
推荐答案
如果你试图检查未选中的复选框的值,我不认为他们会可以使用 structKeyExists(FORM,'f1')
来检查值是否存在。
If you are trying to check the values of unchecked checkboxes I don't think they will show up in the FORM scope. If the checkboxes are checked, then they should show up. You can use structKeyExists(FORM, 'f1')
to check if a value exists.
这篇关于不从复选框拾取表单值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!