Tag: 形成

Node.js表单插件类似于Rails?

正如标题所述,我正在寻找Node.js中的某种表单插件,这将允许我以类似于Rails的方式创build表单。 我遇到过几个Node.js表单插件,最近的一个是Formed 。 但是,该插件是特定于Sequelize(我正在使用JugglingDB)。 理想情况下,做一些类似于下面的事情会很好(假设EJS): <%- form_for(user, function(form) { %> <%- form.input('username') %> <%- form.input('password') %> <%- form.submit() %> <%- }) %> 输出类似于以下内容: <form action="/users" method="post" id="new_user_form"> <div class="input required"> <label for="user_username">Username</label> <input type="text" name="user_username" id="new_user_form_user_username"/> </div> <div class="input required"> <label for="user_password">Password</label> <input type="password" name="user_password" id="new_user_form_user_password"/> </div> <input type="submit" name="user_submit" value="Create User"/> </form> 我遇到的唯一的其他插件似乎有一些以下和最近的更新是强大的 。 […]

我得到警告:IntentDialog – 当我填写表单Node.js僵尸框架找不到null的意图处理程序

我对node.js和bot框架非常陌生。 我在我的机器人中运行的json中创build了一个表单。 然而,填写表格后,我得到的错误 / – WARN: IntentDialog – no intent handler found for null 我不确定这是为什么。 我正在使用.addAttachment来使用卡和session.send(味精)呈现给用户的forms。 但是,表单完成并提交后,我得到上述错误信息。 下面是正在使用的表单和node.js中的代码 var card = { 'contentType': 'application/vnd.microsoft.card.adaptive', 'content': { '$schema': 'http://adaptivecards.io/schemas/adaptive-card.json', 'type': 'AdaptiveCard', 'version': '1.0', 'body': [ { 'type': 'Container', 'items': [ { } ] } ], 'actions': [ // Contact Information Form { 'type': 'Action.ShowCard', 'title': 'Contact […]

如何从服务器端的多个input字段(Express.js / Node.js)中查找数据?

我有一个具有多个描述文本字段的表单,文件select字段并提交跨域请求(CORS变体)button: <form class="upload" id="upload_form" enctype="multipart/form-data" method="post" action="http://localhost:3001/upload/1234567890"> <div class="row-fluid"> <div class="span5 row-fluid" id="description" style="margin-left:0px;"> <div> <label>Title</label> <input class="span12" type="text" placeholder="Title" id="description_title" name="description_title"/> <label>Author</label> <input class="span12" type="text" placeholder="Author" id="description_author" name="description_author"/> <label>Tags</label> <input class="span12" type="text" placeholder="Tags" id="description_tags" name="description_tags"/> <label>Description</label> <textarea class="span12" id="description_textarea" name="description_textarea" rows="5" style="resize:none"></textarea> <div id="buttons" class="row-fluid" style="margin-top: 5px"> <div class="span12"> <span class="span5 btn btn-primary btn-file" […]

HTML + Node.jsfile upload

请帮我解决这个问题。 结果我得到空值 。 HTML代码 <form method="post" enctype="multipart/form-data" action="/file-upload"> <input type="text" name="username"> <input type="password" name="password"> <input type="file" name="thumbnail"> <input type="submit"> </form> Node.js的 var express = require('express'); var http = require('http'); var request = require('request'); var bodyParser = require('body-parser'); var app = express(); app.use(express.static(__dirname + '/app/')); // parse urlencoded request bodies into req.body app.use(bodyParser.urlencoded({ extended: true })); […]

使用Mongodb和node.js在一个页面中处理多个表单

我在同一页面上login和注册。 我已经指定了两个不同的path发布数据,但是当我点击registry单末尾的注册button时,它保存了login表单input(这是没有的)? 我看了这个问题( 多个表单和一个处理页面 )。 它如何与节点工作,这意味着我必须创build一个模块为不同的forms? 这是我的代码。 我最后还有一个小脚本也是因为我的引导模板的滑块function与提交function冲突。 <h2>Register<h2> <form method="POST" action="/samples"> <input type="text" name="fullName" id="fullName" class="input-lg " placeholder="your full name" data-required="true"> <input type="text" name="age" id="age" class="input-lg" placeholder="age"> <input type="text" name="city" id="city" class="input-lg" placeholder="Your City"> <input type="text" name="job" class="input-lg" placeholder="Your Job"> <input type="text" name="username" class="input-lg " placeholder="prefered username" data-required="true"> <input type="password" name="password" class="input-lg" placeholder="Password"> <input […]

Node.js中的多页表单

我正在制作一个项目,我想要将表单分成多个页面。 我们目前正在使用express for node.js。 是否有可能从一个页面存储variables,并继续传递给后续页面? 第一页被称为“注册”,指向“指示”。 来自指令的代码snippit如下所示: app.post('/instructions', function(req, res){ res.render('instructions.ejs', {book-code=req.body.book-code, pages=req.body.pages, author=req.body.author, title=req.body.title}); }); instructions.ejs页面上的隐藏窗体如下所示: <form action = "record" method="POST"> <input type="hidden" name="iauthor" value="author"> <input type="hidden" name="ipages" value="pages"> <input type="hidden" name="ibook-code" value="book-code"> <input type="hidden" name="ititle" values="title"> </form> 然后,从ejs文件logging的部分是: app.post('/record', function(req, res){ pg.connect(process.env.DATABASE_URL, function(err, client, done) { client.query('INSERT INTO database(book, PAGES, NAME, TITLE) VALUES($1)', […]

保存/devise嵌套forms,根据mongoose模式,通过mongoose在mongodb中保存/更新数据

我创build了以下mongoose模式来保存mongodb中的测验 – var answerSchema = new Schema({ answer: String, correct: Boolean }); var questionSchema = new Schema({ title: String, tag: String, chapterName: String, marks: Number, negativeMarks: Number, correctAnswerExplanation: String, hint: String, answers: [answerSchema] }); var quizSchema = new Schema({ courseId: Number, courseName: String, lectureId: Number, lectureName: String, popupTime: Number, teacherName: String, questions: [questionSchema] }); var […]

如何使用Nodemailer从表单发送电子邮件

让我们开始说我是节点和JavaScript的初学者。 我有一个使用HTML,CSS和ASP.NET构build的网站。 在我的网站上有一个电子邮件表单设置,我想从ASP.NET转换到Node.js只是为了学习的经验。 我跟着几个不同的教程试图让这个工作。 我一直在提醒你 我已经成功地使我的HTML电子邮件表单接受数据和节点捡起来。 但是试图抓取节点并使用nodemailer以电子邮件的forms发送,而不是那么多。 我注意到几个教程使用“路线”我想避免这个选项,因为它只是超越了我的头。 如果有人能解释如何做到这一点,或为什么不这样做或不能做到这一点? 我会感激。 这是我迄今为止的代码: 使用Javascript /节点: var nodemailer = require('nodemailer'); var bodyParser = require('body-parser'); var express = require('express'); var app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.post('/contact', function (req, res) { var mailOpts, smtpConfig; //Setup Nodemailer transport, I chose gmail. Create an application-specific password to avoid problems. smtpConfig […]

在Strongloop中同时保存多个模型

我正在开发一个完全基于StrongLoop REST API的应用程序作为后端。 有一个registry单。 用户填写个人信息以及他/她所在公司的一些详细信息。 用户和公司是不同的模型,并有一个“有一个”的关系。 validation+同时将表单保存到两个模型的最佳方法是什么? (最好在一个请求中) 有几件事情可以使这个成为可能,但是我找不到任何有关它的文档,或者有点难看: 包含相关公司模型的POST请求,类似于GET请求中存在的筛选器[include]选项。 在不实际保存模型的情况下获取validation错误的一种方法,因此您可以在两个模型validation后保存整个表单(但是,需要多个请求) 将整个表单发送到用户模型,并保存公司模型服务器端。 有什么想法吗?

KoaJS如何从多部分表单数据获取文件?

当我发布多部分表单时, <form name="acount_manage" action="/update" enctype="multipart/form-data" method="post"> <input type="file" name="file"> </form> 它抛出: Error: Unsupported content-type: multipart/form-data at Object.<anonymous> (e:\…\node_modules\co-body\lib\any.js:51:15) any.js: /** * Module dependencies. */ var json = require('./json'); var form = require('./form'); var text = require('./text'); var JSON_CONTENT_TYPES = [ 'application/json', 'application/json-patch+json', 'application/vnd.api+json', 'application/csp-report', 'application/ld+json' ]; /** * Return aa thunk which parses form and […]