Hi I am trying to get the Radio button value from my jade page into the js file and unable to achieve it. I wish to show the value taken from the form to be displayed as a table format on the browser.
The radio button value does not reach the js file itself as i have tried with console.log option
I have tried with function calls and it does not seem to achieve either. Below is my jade file which I am trying to send it to js file
doctype
html
head
title Add new comment
body
h3 Comment Details
form(id='form', method='post', action='/comment/create')
print Select the severity
<br/>
input(type='radio',name='severity',value ='Minor', onclick = 'func(type)')
print Minor  
input(type='radio',name = 'severity')
print Major  
input(type='radio',name = 'severity')
print Critical  
<br/><br/>
input(type='submit', value='Add Comment')
var CommentApi = require('../data/CommentApi');
var express = require('express');
var router = express.Router();
router.get('/', function(req, res) {
CommentApi.getAllComments(function(err, items) {
res.render('comment/index', {title: 'Comments', comments: items})
});
});
router.get('/create', function(req, res) {
res.render('comment/create');
});
function func()
{
var type = document.getElementByName("severity");
console.log('type');
}
router.post('/create', function(req, res) {
var comment = {};
console.log('type');
comment.author = req.body.author;
comment.text = req.body.text;
comment.severity = req.body.severity;
comment.crdate = req.body.crdate;
commment.rdate = req.body.rdate;
CommentApi.saveComment(comment, function(err, comment) {
res.redirect('/comment');
});
});