Tutorialspoint

Programming Examples

HTML DOM Input Range autofocus property

<!DOCTYPE html>
<html>
<body>
<h1>Input range autofocus property</h1>
<form>
<input type="range" id="RANGE1" name="VOL" autofocus>
</form>
<br>
<button type=”button” onclick="rangeFocus()">CHECK</button>
<p id="Sample"></p>
<script>
function rangeFocus() {
var R = document.getElementById("RANGE1").autofocus;
document.getElementById("Sample").innerHTML = "The autofocus property is set to: "+R;
}
</script>
</body>
</html>

HTML DOM Input Radio value Property

<!DOCTYPE html>
<html>
<body>
<h1>Input radio Value property</h1>
<form>
FRUIT:
<input type="radio" name="fruits" id="BTN1" value="Mango" >Mango
<br>
</form>
<p>Get the above element value by clicking the below button</p>
<button type=”button” onclick="getValue()">Get Value</button>
<p id="Sample"></p>
<script>
function getValue() {
var t = document.getElementById("BTN1").value;
document.getElementById("Sample").innerHTML = "The value for the radio button is : "+t;
}
</script>
</body>
</html>

HTML DOM Input Radio type property

<!DOCTYPE html>
<html>
<body>
<h1>Input radio type Property</h1>
<form>
FRUIT:
<input type="radio" name="fruits" id="Mango">Mango
<br>
</form>
<p>Get the above input element type by clicking the below button</p>
<button type="button" onclick="radioType()">GET Type</button>
<p id="Sample"></p>
<script>
function radioType() {
var P=document.getElementById("Mango").type;
document.getElementById("Sample").innerHTML = "The type for the input field is: "+P ;
}
</script>
</body>
</html>

HTML DOM Input Password type property

<!DOCTYPE html>
<html>
<body>
<h1>password type property</h1>
PASSWORD: <input type="password" id="PASS1">
<p>Get the above element type by clicking the below button</p>
<button onclick="getType()">Get Type</button>
<p id="Sample"></p>
<script>
    function getType() {
    var t = document.getElementById("PASS1").type;
     document.getElementById("Sample").innerHTML = "The type for the input field is : "+t;
    }
</script>
</body>
</html>

C++ Average of Squares of n Natural Numbers

cpp

#include<iostream>

using namespace std;
int main() {
  long n, i, sum = 0, d;
  n = 3;
  for (i = 1; i <= n; ++i) {
    d = i * i;
    sum += d;
  }
  cout << sum / n;
  return 0;
}

HTML DOM Meter min Property

<!DOCTYPE html>
<html>
<head>
<title>Meter min</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
} input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Meter-min</legend>
<label for="paulaLifeSource">Paula's Health Risk: </label>
<meter id="paulaLifeSource" max="100" min="0" high="80" low="60" value="60"
optimum="40"></meter>
<input type="button" onclick="lifeSource()" value="Medi Kit">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
divDisplay.textContent = 'Life Source at '+paulaLifeSource.value+'/'+paulaLifeSource.max;
function lifeSource(){
var paulaLifeSource = document.getElementById("paulaLifeSource");
var Immunity = paulaLifeSource.min;
paulaLifeSource.min = 20;
divDisplay.textContent = 'Permenant Damage to '+paulaLifeSource.min+' from '+Immunity;
}
</script>
</body>
</html>

HTML DOM Meter max Property

<!DOCTYPE html>
<html>
<head>
<title>Meter max</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
} input[type="button"] { border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Meter-max</legend>
<label for="paulaLifeSource">Paula's Health Risk: </label>
<meter id="paulaLifeSource" max="100" min="0" high="80" low="60" value="70"></meter>
<input type="button" onclick="lifeSource()" value="Medi Kit">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
divDisplay.textContent = 'Life Source at '+paulaLifeSource.value+'/'+paulaLifeSource.max;
function lifeSource(){
var paulaLifeSource = document.getElementById("paulaLifeSource");
var Immunity = paulaLifeSource.max;
paulaLifeSource.max = 80;
divDisplay.textContent = 'Life Decreased to '+paulaLifeSource.max+' from '+Immunity;
}
</script>
</body>
</html>

HTML DOM Meter low Property

<!DOCTYPE html>
<html>
<head>
<title>Meter low</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
} input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Meter-low</legend>
<label for="paulaLifeSource">Paula's Health Risk: </label>
<meter id="paulaLifeSource" max="100" min="0" high="80" low="60" value="70"></meter>
<input type="button" onclick="lifeSource()" value="Medi Kit">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
divDisplay.textContent = 'Life Source at '+paulaLifeSource.value;
function lifeSource(){
var paulaLifeSource = document.getElementById("paulaLifeSource");
var Immunity = paulaLifeSource.low;
paulaLifeSource.low = 75;
divDisplay.textContent = 'Immunity increased to '+paulaLifeSource.low+' from '+Immunity;
}
</script>
</body>
</html>

HTML DOM Meter high Property

<!DOCTYPE html>
<html>
<head>
<title>Meter high</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
} input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Meter-high</legend>
<label for="paulaLifeSource">Paula's Health Risk: </label>
<meter id="paulaLifeSource" max="100" min="0" high="80" low="70" value="85"></meter>
<input type="button" onclick="lifeSource()" value="Medi Kit">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
divDisplay.textContent = 'Life Source at '+paulaLifeSource.value;
function lifeSource(effect){
var paulaLifeSource = document.getElementById("paulaLifeSource");
var Immunity = paulaLifeSource.high;
paulaLifeSource.high = 90;
divDisplay.textContent = 'Immunity increased to '+paulaLifeSource.high+' from '+Immunity;
}
</script>
</body>
</html>

HTML DOM Meta Object

<!DOCTYPE html>
<html>
<head>
<title>Meta Object</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
} input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Meta-Object</legend>
<h2>Tutorial</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</p>
<input type="button" onclick="createMeta()" value="Create Meta Tag">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
function createMeta(){
var metaTag = document.createElement('META');
metaTag.setAttribute("name", "tutorialsContent");
metaTag.setAttribute("content", "JS tutorials");
document.head.appendChild(metaTag);
divDisplay.textContent = '<meta name="'+metaTag.name+'" content="'+metaTag.content+'" >';
}
</script>
</body>
</html>

Previous 1 ... 4 5 6 7 8 9 10 ... 8483 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.