本文介绍了通过单击表格单元格使用jquery提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
表单怎么可能只提交clickt表格单元格的输入"字段
How is this possible that the form submit only the "input" field of the clickt table cell
<form id="switch" method="POST">
<table>
<tr>
<td>some content<input type="hidden" name="switch_value" value="1"></td>
<td>some content<input type="hidden" name="switch_value" value="2"></td>
<td>some content<input type="hidden" name="switch_value" value="3"></td>
<td>some content<input type="hidden" name="switch_value" value="4"></td>
<td>some content<input type="hidden" name="switch_value" value="5"></td>
</tr>
</table>
</form>
推荐答案
尝试一下:
<form id="switch" method="POST">
<table>
<tr>
<td><label>some content<input type="radio" name="switch_value" value="1"></label></td>
<td><label>some content<input type="radio" name="switch_value" value="2"></label></td>
<td><label>some content<input type="radio" name="switch_value" value="3"></label></td>
<td><label>some content<input type="radio" name="switch_value" value="4"></label></td>
<td><label>some content<input type="radio" name="switch_value" value="5"></label></td>
</tr>
</table>
</form>
<script>
$(document).ready(function(){
$('#switch input[type="radio"]').change(function(){
$('#switch').submit();
});
});
</script>
我以这种方式在label
之间包裹了文本和单选按钮,即使您使用CSS隐藏radio buttons
,文本也会将事件传播到单选按钮.
I wrapped the text and the radio buttons between label
that way, even if you use css to hide the radio buttons
, the text would propagate the event down to the radio button.
这篇关于通过单击表格单元格使用jquery提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!