Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72358

accessing variable of node into html file

$
0
0

I have an index.html file and an app.js nodejs file. I have a var in app.js which is the name and want to print that variable in my index.html page

Code

var name = "Utsav";
var HTTP = require('HTTP');
var fs = require('fs');

function onRequest(req, res){
     fs.readFile('index.html', function(err, data) {
        res.writeHead(200, {'Content-Type': 'text/html'});
        res.write(data);
        res.end();
    });
}

<html lang="en">
<head>
    <title>Enter your request</title>
</head>
<body>
   <label for="Name:">Name</label><br>
   <input type="text" id="req"><br>
</body>

I want the value of name from app.js to print in a text box in index.html


Viewing all articles
Browse latest Browse all 72358

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>