Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7987653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:12:37+00:00 2026-06-04T12:12:37+00:00

I write some script for sum 3 numbers with express and jade… on index.jade

  • 0

I write some script for sum 3 numbers with express and jade…

on index.jade i have a 3 fields and submit button:

!!! 5
html
  head
    title Test
  body
    form(name='form1', method='post', action='')
      label(for='1')
      input#1(type='text', name='1')
      label(for='2')
      input#2(type='text', name='2')
      label(for='3')
      input#3(type='text', name='3')
      input(name='submit', type='button', value='submit') 
    span #{result}

and on serverside (js code- node.js) I have this code:

var express = require('express');
        app = express.createServer();

app.configure(function(){
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
});
app.use(express.bodyParser());
    app.get('/', function(req, res){
     res.render('index');
    });


    app.post('/', function(req, res){
      var i = req.param('1', null);
      var j = req.param('2', null);
      var k = req.param('3', null);
      var r = i+j+k;
      res.render('index', {result:r});

    });
app.listen(3010);

but every time I start the js file via node app.js I goy message that the object is not defined and some errors in jade file:

How to define object in app.js file?

error:

ReferenceError: C:\Users\PC\glowing-frost-5319/views/index.jade:14
    12. '      input#3(type=\'text', name='3')
'
    13. '      input(name=\'submit', type='button', value='submit') 
'
    14. '    #{result}'

result is not defined
    at Object.<anonymous> (eval at <anonym... etc.

Anybody can tell me how to define object result and how to show on index.jade page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:12:38+00:00Added an answer on June 4, 2026 at 12:12 pm

    I think you need to pass result in the second parameter to the render method in your get route (just as you are already doing in the post route).

    Try this:

    app.get('/', function(req, res){
        res.render('index', {result: ''});
    });
    

    This will make the result variable available in your view (with a value of empty string in this example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a script before page load to write some html into my
How do I write some client-side script to access a HTML element when .NET
I am try to write some validation script using javascript and prototype. What I
I am trying to write a simple (for some) script that will get the
I'm trying to write an MsBuild script to zip some files up. I need
I am trying to write a bash script(script.sh) to search and replace some variables
Today I wanted to write a simple php script, but I got some annoying
I have to use windows to write some shell scripts. I decided to use
I want to write some python package installing script in Python into virtualenv. I
I'm trying to write some code that various sites will embed, calling a script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.