禁用时未使用表单提交HTML选项控件 [英] HTML select option control when disabled is not submitted with the form
问题描述
我有以下HTML代码。我需要根据另一个客户端控件中的选择灰显此控件。我是这样使用jQuery:
I have the following HTML code. I need to gray out this control depending on the selection in another client-side control. I do it like so using jQuery:
$('#dropDown1').attr('disabled', 'disabled');
问题是如果禁用此控件,则不会随表单一起提交。有没有办法克服这个问题?
The problem is that this control, if disabled, is not submitted with the form. Is there any way to overcome this?
同样,我需要以某种方式阻止用户在某些情况下编辑控件(不是所有时间),但仍然可以使用表单提交。
Again, I need to somehow be able to prevent user from editing control in certain situations (not all the time) but still be able to submit it with the form.
<select name="dropDown1" id="dropDown1">
<option value="1">1</option>
<option value="2">2</option>
</select>
推荐答案
这是一个代码示例,向您展示如何删除<提交表单前code>已停用属性
here's a code example showing you how to remove the disabled
property before submitting the form
http://jsfiddle.net/manuel/dy9Zc/
实际上诀窍就是删除<上的attr code>提交表格事件
actually the trick is to just remove the attr on the submit
event of the form
这篇关于禁用时未使用表单提交HTML选项控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!