Answer the question
In order to leave comments, you need to log in
There are 4 forms on the page for submitting data. How to process only one form in nodejs when clicking on a button in the desired form?
There are 4 forms. She is different. But when you click, all forms on this page will be processed. How to do that only the necessary one was processed. On php it was easier there was just an ISSET function.
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Главная'});
});
/* POST home page. */
router.post('/', function(req, res, next) {
res.send("modal=1");
});
Answer the question
In order to leave comments, you need to log in
<form>
<input type='hidden' name='action' value='form_one'>
</form>
router.post( '/', function( req, res, next ) {
if ( req.body.action === 'form_one' ) {...}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question