app.js
/** * module dependencies. */ var express = require('express'); var routes = require('./routes'); var http = require('http'); var path = require('path'); var app = express(); // environments app.set('port', process.env.port || 3000); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.json()); app.use(express.urlencoded()); app.use(express.methodoverride()); app.use(app.router); app.use(require('stylus').middleware(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'public'))); // development if ('development' == app.get('env')) { app.use(express.errorhandler()); } app.get('/', routes.index); app.get('/about', routes.about); app.get('/contact', routes.contact); app.get('/movieslist', routes.movieslist); app.get('/addmovie', routes.addmovie); app.post('/movieadded', routes.movieadded);
index.js
exports.movieadded = function (req, res) { console.log(req.body); res.render('movieadded', req.body); };
addmovie.jade
extends layout block content br form(action="/movieadded", method="post") input(type="text", name="movie" ,value="movie") br input(type="number", name="rating", value="rating") br input(type="number", name="year", value="year") br input(type="submit" value="submit")
when hit submit button, doesn't post on console or doesn't show in browser. in other words being idle. tried many ways appreciated.
you need tab in inputs:
extends layout block content br form(action="/movieadded", method="post") input(type="text", name="movie" ,value="movie") br input(type="number", name="rating", value="rating") br input(type="number", name="year", value="year") br input(type="submit" value="submit")
if don't put tab under form render inputs outside of form.
so, tab required make inputs children of form.
Comments
Post a Comment