CODE:
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Functions in JavaScript</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<style>
*{
padding: 10px;
}
</style>
<script>
function fun1() {
var rd1 = document.getElementById("rd1");
var rd2 = document.getElementById("rd2");
if(rd1.checked==true){
alert("The selected is : "+rd1.value);
}
else if(rd2.checked==true)
alert("The selected is : " +rd2.value);
else
alert("Nothing selected");
}
</script>
</head>
<body>
<h1>Select any one from below: </h1>
<input id="rd1" name="radio1" type="radio" value="JavaScript" required></input>
<labeL><strong>JavaScript</strong></label><br />
<input id="rd2" type="radio" name="radio1" value="Bootstrap" required>
<labeL><strong>Bootstrap</strong></label><br />
<button onclick="fun1()" id="btn1">Click Me</button>
</body>
</html>
OUTPUT:
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Functions in JavaScript</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<style>
*{
padding: 10px;
}
</style>
<script>
function fun1() {
var rd1 = document.getElementById("rd1");
var rd2 = document.getElementById("rd2");
if(rd1.checked==true){
alert("The selected is : "+rd1.value);
}
else if(rd2.checked==true)
alert("The selected is : " +rd2.value);
else
alert("Nothing selected");
}
</script>
</head>
<body>
<h1>Select any one from below: </h1>
<input id="rd1" name="radio1" type="radio" value="JavaScript" required></input>
<labeL><strong>JavaScript</strong></label><br />
<input id="rd2" type="radio" name="radio1" value="Bootstrap" required>
<labeL><strong>Bootstrap</strong></label><br />
<button onclick="fun1()" id="btn1">Click Me</button>
</body>
</html>
OUTPUT:
No comments:
Post a Comment