The most viewed posts

Registry Reviver

How to clean up Windows Computer

About Desktop Icons in Windows Computer

Driver Booster

CCleaner

Myanmar font and keyboard for Windows

Advanced System Care

some (JavaScript Array Method)

How to make a computer secure and run faster

How to sell IT materials in zilastar.com

The most viewed items

Desktop Hard Disk

Dell Inspiron 5559

HP ProBook 430

SONY Playstation Portable

Laptop RAM

External Hard Disk

Laptop

ZilaStar ICT Jun 20 2022, 09:39:01

for (JS For Loop)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo"></p>
<script>
var names = ["Maung Maung", "Aung Aung", "Mya Mya", "Hla Hla"];
var i, txt;

txt = "<ol>";
for(i=0; i<names.length; i++){
txt += "<li>" + names[i] + "</li>";
}
txt += "</ol>";

document.getElementById("demo").innerHTML = txt;

</script>
</body>
</html>


ZilaStar ICT Jun 19 2022, 09:37:54

forin (JS For Loop)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo"></p>
<script>
var names = ["Maung Maung", "Aung Aung", "Mya Mya", "Hla Hla"];
var i, txt;

txt = "<ol>";
for(i in names){
txt += "<li>" + names[i] + "</li>";
}
txt += "</ol>";

document.getElementById("demo").innerHTML = txt;

</script>
</body>
</html>


ZilaStar ICT Jun 18 2022, 09:36:53

JS Form Validation

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<script>
function formValidate(){
var x = document.forms["myForm"]["fname"].value;
if(x == ""){
alert("Must fill out in the form");
return false;
}
}
</script>
</body>
<form action = "formvalidate1.html" method = "POST" onsubmit = "return formValidate()" name = "myForm">
<input type = "text" name = "fname">
<input type = "submit" value = "Submit">
</form>
</html>


ZilaStar ICT Jun 17 2022, 09:35:47

Throw Statement (JS Errors)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<input id = "demo" type = "text">
<button type = "button" onclick = "jsFun()">Check Input</button>
<p id = "page"></p>
<script>
function jsFun(){
var sms, x;
sms = document.getElementById("page");
sms.innerHTML = "";
x = document.getElementById("demo").value;
try{
if(x == "") throw "empty.";
if(isNaN(x)) throw "not a number.";
x = Number(x);
if(x < 5) throw "too small.";
if(x > 10) throw "too big.";
if(x > 4 && x < 11) throw "OK.";
}
catch (err){
sms.innerHTML = "The input is " + err;
}
}
</script>
</body>
</html>


ZilaStar ICT Jun 16 2022, 09:35:11

Finally Statement (JS Errors)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Cdoe Testing</title>
</head>
<body>
<input id = "demo" type = "text">
<button type = "button" onclick = "jsFun()">Check Input</button>
<p id = "page"></p>
<script>
function jsFun(){
var sms, x;
sms = document.getElementById("page");
sms.innerHTML;
x = document.getElementById("demo").value;
try {
if (x == "") throw "empty.";
if (isNaN(x)) throw "not a number.";
x = Number(x);
if(x < 5) throw "too small.";
if(x > 10) throw "too big.";
if(x > 4 && x < 11) throw "OK.";
}

catch (err){
sms.innerHTML = "The Input is " + err;
}

finally{
document.getElementById("demo").value;
}
}
</script>
</body>
</html>


ZilaStar ICT Jun 15 2022, 09:33:58

JS Arrow Function

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<button id = "btn1">Try Now</button>
<p id = "demo1"></p>

<button id = "btn2">Try Now</button>
<p id = "demo2"></p>

<script>
var test1 = function(){
document.getElementById("demo1").innerHTML += this;
}

//window object calls the function
window.addEventListener("load", test1);

//button object calls the function
document.getElementById("btn1").addEventListener("click", test1);

var test2 = () =>{
document.getElementById("demo2").innerHTML += this;
}

//window object calls the function
window.addEventListener("load", test2);

//button object calls the function
document.getElementById("btn2").addEventListener("click", test2);

</script>
</body>
</html>


ZilaStar ICT Jun 14 2022, 08:04:31

Inheritance (JS Classes)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo">Inheritance Test</p>
<script>
class Car{
constructor(brand){
this.carname = brand;
}
present(){
return "I have " + this.carname;
}
}

class Model extends Car{
constructor(brand, mod){
super(brand);
this.model = mod;
}
show(){
return this.present() + " and the model is " + this.model + ".";
}
}
var myCar = new Model("Tesla", "2021");
document.getElementById("demo").innerHTML = myCar.show();
</script>
</body>
</html>


ZilaStar ICT Jun 13 2022, 08:03:15

Getter and Setter (JS Classes)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo"></p>
<script>
class Car{
constructor(brand){
this.carname = brand;
}
get cnam(){
return this.carname;
}
set cnam(x){
this.carname = x;
}
}
const myCar = new Car["Tesla"];
document.getElementById("demo").innerHTML = myCar;
</script>
</body>
</html>


ZilaStar ICT Jun 12 2022, 08:02:28

Creating Object (JS Classes)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id ="demo"></p>
<script>
class Name{
constructor(Name, City){
this.name = Name;
this.city = City;
}
}

var newName = new Name("Thet", "Yangon");
document.getElementById("demo").innerHTML = newName.name + " stays in " + newName.city + ".";

</script>
</body>
</html>


ZilaStar ICT Jun 11 2022, 08:01:10

Class Methods (JS Classes)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo">What is your name and age?</p>
<button type = "button" onclick = "jsFun()">Check Name and Age</button>
<script>
function jsFun(){
class Name{
constructor(Name, Year){
this.name = Name;
this.year = Year;
}

age(){
const date = new Date();
return date.getFullYear() - this.year;
}
}

const myName = new Name("Thet", 1987);
document.getElementById("demo").innerHTML = "My name is " + myName.name + " and my age is " + myName.age() + " years old now.";
}
</script>
</body>
</html>


ZilaStar ICT Jun 08 2022, 10:22:01

Reduce() (JS Array Iteration)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo"></p>

<button type = "button" onclick = "jsReduce()">Total</button>&nbsp;&nbsp;
<button type = "button" onclick = "jsReset()">Reset</button>

<script>
var numbers = [302, 428, 49, 92, 84, 70, 80, 10, 3, 200];
var num = numbers.sort(function(a, b){return a - b;}).join("<br/>");
document.getElementById("demo").innerHTML = num;

function jsReset(){
document.getElementById("demo").innerHTML = num;
}

function jsReduce(){
var number2 = numbers.reduce(funReduce);
document.getElementById("demo").innerHTML = number2;
}

function funReduce(total, value){
return total + value;
}


</script>
</body>
</html>


ZilaStar ICT Jun 07 2022, 10:21:20

Map() (JS Array Iteration)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo"></p>
<button type = "button" onclick = "jsDouble()">Double</button>&nbsp;&nbsp;
<button type = "button" onclick = "jsReset()">Reset</button>&nbsp;&nbsp;
<button type = "button" onclick = "jsTriple()">Triple</button>
<script>
var numbers = [302, 428, 49, 92, 84, 70, 80, 10, 3, 200];
var num = numbers.sort(function(a, b){return a - b;}).join("<br/>");
document.getElementById("demo").innerHTML = num;


function jsReset(){
document.getElementById("demo").innerHTML = num;
}

function jsDouble(){
number2 = numbers.map(mapDouble).join("<br/>");
document.getElementById("demo").innerHTML = number2;
}

function jsTriple(vlaue){
number3 = numbers.map(mapTriple).join("<br/>");
document.getElementById("demo").innerHTML = number3;
}

function mapDouble(value){
return value*2;
}

function mapTriple(value){
return value*3;
}
</script>
</body>
</html>


Page : 6 of 30
To Contact
Available Services
Terms and Conditions