0
我目前正在构建一个非常简单的cms。因此,您只需在文本框旁边添加一个“”更多“按钮,当您按下它时,它会插入一个新创建的文本框。什么是将数组从jade传递到节点js的最佳方式
,所以我希望能够从每个创建的文本框获得所有这些值,并将其上传到服务器
我试图寻找它,但是一无所获atall! urghh有人可以请大家帮帮忙:)
这是我到目前为止的代码
app.js
router.post('/addname', function(req, res) {
// connect to the results collection
var db = req.db;
var collection = db.get('names');
// Get form values.
var content = req.body.names;
// Submit to the DB
collection.insert({
"content": content
}, function (err, doc) {
if (err) {
// If it failed, return error
res.send("There was a problem adding the information to the database.");
console.log(err);
}
else {
// And forward to success page
res.redirect("/");
}
});
玉
form(action='addname' method="post")
div#mynames()
button#addmore(style="margin-left:-220px;" onClick="addtextbox") Add more
input#names(name='names' placeholder='@', type='text')
jQuery的
function addTexbox(){
$("#names").append('<br><input placeholder="@" type="text" style="border-radius: 15px; border: none;" />');
// contains all name input element
var allname = $("#names:input");
console.log(allTags[0].value);
}
到目前为止,它可以的,如果按下按钮
谢谢产生新的文本框!