how to use js variable in html code example

Example 1: js variable html

<div onload="document.innerHTML(name + ' is ' + age)">

Example 2: Create variable javascript

//Assigns the value bar to the variable foo
var foo = bar;

Example 3: how to make a variable in php

$varName = "Hello, World";

Example 4: html define javascript variable

<script>
var Number = 5;
var String = "Hi!";
var boolen1 = true;
var boolen2 = false;
var array = [11, "Hi!", true];
var object = {age:11, speach:"Hi!", likes_Bananas:true};
</script>

Example 5: How to pass variables from js to html node

var bodyParser = require('body-parser');
var express = require('express');
var app = express();

app.use(express.static(__dirname + '/'));
app.use(bodyParser.urlencoded({extend:true}));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.set('views', __dirname);

app.get('/', function(req, res){
    res.render('index.html',{email:data.email,password:data.password});
});

Tags:

Php Example