Is there a possible case where appending a textarea
on page load won't be included inside the form
post? however, hardcoding it in PHP works fine?
I would post the whole code, but I'm using PyroCMS fieldTypes and I'm not sure if many know it.
Here's the JS code:
$(function() {
$(".list_field").append('<li><textarea name="work_and_education[3]" class="item_input" placeholder="List item content..."></textarea><div class="btn gray add" id="add_btn">+</div><div class="btn gray remove" id="remove_btn">-</div></li>');
});
UPDATE:
Here's how the html looks like after loading the page: The textarea that contains values are done by php.
<div class="input">
<ul class="list_field" id="work_and_education">
<li><textarea name="work_and_education[0]" class="item_input" placeholder="List item content...">testin1</textarea><div class="btn gray add" id="add_btn">+</div><div class="btn gray remove" id="remove_btn">-</div></li>
<li><textarea name="work_and_education[3]" class="item_input" placeholder="List item content..."></textarea><div class="btn gray add" id="add_btn">+</div><div class="btn gray remove" id="remove_btn">-</div></li>
<li><textarea name="work_and_education[2]" class="item_input" placeholder="List item content...">testing2</textarea><div class="btn gray add" id="add_btn">+</div><div class="btn gray remove" id="remove_btn">-</div></li>
</ul>
</div>
这应该起作用,但是,如果您使用它来添加许多文本区域,则它们应具有唯一的名称以及可能的ID。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.