Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Question #1-

<head>

<script>
function Check(){
var t1 = document.getElementById("t1").value;
var t2 = document.getElementById("t2").value;

if(t1 == t2)
alert("Both text fields are identical");
else
alert("text fields are not identical");
}
</script>
</head>

<body>
<form>
<pre>
Field 1 <input type="text" id="t1" />

Field 2 <input type="text" id="t2" /> <input type="button" value="Check" onclick="Check()" />
</pre>
</form>
</body>

Question #2-

<head>
<script>
function Check(){
var x = document.getElementById("n");

if(x.value == "" || isNaN(x.value)){


alert("Invalid entry");
x.focus();
}
else
if(x.value % 2 == 0)
alert("Even number");
else
alert("Odd number");
}
</script>
</head>

<body>
<form>
Enter a number: <input type="text" id="n" />

<input type="button" value="Check" onclick="Check();" />

</form>
Question #3-

function Mul(n){
for(i=1; i<=10; i++){
document.write(i + " x " + n + " = " + i*n + "<br/>");
}
}

Question #4-

<body>
<form>
Course
<select name="courses" onchange="coef.value = this.value;">
<option value="12">JAVA</option>
<option value="10">DS</option>
<option value="14">UML</option>
<option value="12">Mobile</option>
</select>
Coef <input type="tex" name="coef" size="12" />
</form>

</body>

You might also like