Activity #1 (Finals) Change Button Properties on Change Event



MANILING - ACTIVITY 1 (FINALS)

Youtube link: https://youtu.be/6EnkCpqy9cY 



HTML CODE:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Change Button Properties Onchange Events</title>
<link rel="stylesheet" href="csscode.css">
</head>

<body>
<fieldset>
<h1 style="font-family:'Arial'"> Change Button Properties Onchange Events </h1>

<h3 style="font-family:'Arial'"> Enter Color: </h3>
<input type="text" id="input1"/> <br>
<h3 style="font-family:'Arial'"> Enter Number: </h3>
<input type="number" id="input2" onchange="onchangeevent()"/> <br> <br> <br>
<input class="btn" type="button" id="display1">
<input class="btn" type="button" id="display2">
<input class="btn" type="button" id="display3">
<input class="btn" type="button" id="display4">
<input class="btn" type="button" id="display5">

</fieldset>

<script>
function onchangeevent()
{
document.getElementById("input2");
n=document.getElementById("input2").value;
c=String(document.getElementById("input1").value);
switch(Number(n))
{
case 1: document.getElementById("display1").style.background=c;
document.getElementById("display1").value=c;
break;
case 2: document.getElementById("display2").style.background=c;
document.getElementById("display2").value=c;
break;
case 3: document.getElementById("display3").style.background=c;
document.getElementById("display3").value=c;
break;
case 4: document.getElementById("display4").style.background=c;
document.getElementById("display4").value=c;
break;
case 5: document.getElementById("display5").style.background=c;
document.getElementById("display5").value=c;
break;
default: document.getElementById("display1").style.background=c;
document.getElementById("display1").value=c;
break;
}
}
</script>
</body>
</html>


CSS CODE:

* {

box-sizing: border-box;

}


h1.font1 {

margin-left: 30%;

}


fieldset {

width: 60%;

background-color: #FCE0BC;

padding-left: 20px;

padding-right: 20px;

padding-bottom: 10%;

margin-top: 50px;

margin-left: 18%;

border-style: solid;

border-width: 5px;

border-color: black;

}


.btn {

width: 145px;

height: 90px;

background-color: white;

text-shadow: -1px 1px 0 #ffffff, 1px 1px 0 #ffffff, 1px -1px 0 #ffffff, -1px -1px 0 #ffffff;

font-size: 23px;

font-weight: bold;

float: left;

margin-left: 4px;

}

Comments

Popular posts from this blog

Activity #4 (Finals) Password form to open your blog

Activity #3 (Finals) Counting Drill Game