简体   繁体   English

如何在表单提交中包含文本字段的标签

[英]how can I include the label of a text field on form submit

I have a form that dynamically creates a text field and label for the text field. 我有一个可以动态创建文本字段和文本字段标签的表单。 When I use this.form to get the information submitted, I only get the text field which means very little without the label that goes with it. 当我使用this.form获取提交的信息时,我仅获得文本字段,这意味着没有附带的标签几乎没有意义。

Below is an abridged version of the text which I hope is enough. 下面是该文本的节略版本,我希望足够。 I am using jQuery if that helps. 如果有帮助,我正在使用jQuery。

dynamically created form: / 动态创建的表单:/

/dynamically created based on choice options from a form
<input type="text" id="cV_'+curChoice+'" class="numeric" size="1" value="1"> <label for="cV_'+curChoice+'">'+curChoice+'</label><br><hr>'

<input class='action' id='saveButton' type='button' value='SAVE' onclick='saveChoices()' />

<script>
function saveChoices(){
var choiceNum = this.form;
}

I came up with a solution. 我想出了一个解决方案。 I had to add a name to the field. 我必须在该字段中添加一个名称。

$('#choices').append('<input type="text" name="'+curChoice+'" class="numeric" size="1" value="1">'+curChoice+'<br><hr>');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM