Std XI I.T || Skill Set 3 – JavaScript || SOP4
SOP4: Create event driven JavaScript programs for
the following using appropriate variables, JavaScript inbuilt string functions
and control structures.
- To accept number and validate if the given value is a number or not by clicking on the button.
<!DOCTYPE html>
<html>
<head>
<title>sop4</title>
<script language=javascript>
function val()
{
n=f1.v.value
if(!isNaN(n))
document.write(n+" is a number")
else
document.write(n+" is a not number")
}
</script>
</head>
<body>
<form name=f1>
Enter Value:- <input type=text name=v>
<br><br>
<input type=Submit value=Submit
onClick=val()>
</form>
</body>
</html>
- To calculate addition and division of two numbers.
<!DOCTYPE html>
<html>
<head>
<title>sop4</title>
<script language=javascript>
function add()
{
num1=parseInt(f1.n1.value)
num2=parseInt(f1.n2.value)
add=num1+num2
alert("Addition = " +add)
}
function div()
{
num1=parseInt(f1.n1.value)
num2=parseInt(f1.n2.value)
div=num1/num2
alert("Division = " +div)
}
</script>
</head>
<body>
<form name=f1>
<b>1st Number:- <input type=text
name=n1>
<br><br>
<b>2nd Number:- <input type=text
name=n2>
<br><br>
<input type=button value=Addition
onClick="add()">
<input type=button value=Divide
onClick="div()">
</form>
</body>
</html>
Please make Skill set 4 Tally Post Pls
ReplyDelete