提交表单时动态添加的表单字段未发布
我在动态附加表单元素时遇到问题。
我已使用此代码附加表单元素,
$('#wrap_range_'+id).append("<div style='clear:both; margin:0;'></div>
<select name='range_"+id+"[]'>
<option value=''>-- Select range --</option>
<?php
for($cnt=10; $cnt<500; $cnt+=10) {
echo '<option value=\"'. ($cnt-10) . '-' . $cnt.'\">'. ($cnt-10) . ' - ' . $cnt .'</option>'; }
?>
</select>
<input type='text' name='range_discount_"+id+"[]' >
");
表单元素已成功附加,字段的名称属性符合我的要求。
但问题是,当表单提交时,动态附加的元素不会被发布。
请指导我。 提前致谢。
I have a problem with dynamically appended form elements.
I have used this code to append form elements
$('#wrap_range_'+id).append("<div style='clear:both; margin:0;'></div>
<select name='range_"+id+"[]'>
<option value=''>-- Select range --</option>
<?php
for($cnt=10; $cnt<500; $cnt+=10) {
echo '<option value=\"'. ($cnt-10) . '-' . $cnt.'\">'. ($cnt-10) . ' - ' . $cnt .'</option>'; }
?>
</select>
<input type='text' name='range_discount_"+id+"[]' >
");
the forn elements are appended successfully, the name attribute of the fields are as i require.
But the problem is that when the form submits the dynamically appended elements are not being posted.
Please guide me.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是答案,但我似乎无法发表评论。什么是wrap_range+id。是表单还是表单内的 div 或 span ?如果不是表格,请确保它位于 和 之间。另外,您如何知道他们没有提交,即您在做什么,您期望动态添加的字段中的值但没有得到它们?
This isn't an answer but I can't seem to comment. What is wrap_range+id. Is it the form or a div or span inside the form? If it isn't the form make sure that it is between the and . Also how do you know that they're not submitting i.e. what are you doing that you expect values in the dynamically added fields and are not getting them?