所以这是我的困境,我试图将这些表单保存到创建的页面中。我有一个 jQuery 系统,可以像这样向列表中添加输入:
但我必须将它们保存到页面中,因此通过 jQuery 动态创建它们并使用 PHP 保存。我有正确的想法,我只是不知道从哪里开始。任何帮助都是我的 jQuery 代码:
$(function() {
var labelDiv = $('.addEmail');
var i = $('.customSpan2').size() + 1;
$('#addEmail').live('click', function() {
$('<div class="span5 customSpan2"><label class="customLabel removable">Email '+ i +':</label><form class="bs-docs-example notif-form"><div class="row emailRow"><input type="text" class="inputEmail" placeholder="hotelmobi@mobi.com" name="emailform_'+ i +'" /> <a id="delInput">Remove</a></div></form></div>').appendTo(labelDiv);
i++;
return false;
});
$('#delInput').live('click', function() {
if( i > 1 ) {
$(this).parent('div').remove();
$('div.customSpan2').remove();
i = 1;
// i--;
}
return false;
});
});
HTML
<div class="span5 pushDown tempPush">
<label class="customLabel"><?php echo $lang[$cur_lang]['email']; ?>:</label>
<form class="bs-docs-example notif-form">
<div class="row emailRow">
<input type="text" class="inputEmail" placeholder="hotelmobi@mobi.com">
</div>
</form>
</div>
<div class="addEmail"></div>
</div>
</div>
<div class="row pushDown">
<div class="span3">
</div>
<div class="span6 offset2">
<button type="submit" class="btn btn-success btn-medium" id="addEmail" style="margin-left: -13px;"><?php echo $lang[$cur_lang]['addEmail']; ?></button>
<button type="submit" class="btn btn-primary btn-medium btn-fix"><?php echo $lang[$cur_lang]['save']; ?></button>
</div>
</div>