Create A Webpage Using Form Elements
Create A Webpage Using Form Elements
Experiment No: 6
Exercise:
1. Write a program to create the registration form for creating gmail account.
Code
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<form name="MyForm" method="post" action="">
<h2>Register your account</h2>
Enter your Firstname: <input type="text" name="FName" id="FName"><br><br>
Enter Your Lastname: <input type="text" name="LName" id="LName"><br><br>
Enter your Username: <input type="text" name="UName" id="UName"><br><br>
Enter your Password: <input type="password" name="pass" id="pass"><br><br>
Enter you Gender: <input type="radio" name="Gender" id="Male">Male
21202A0040
<input type="radio" name="Gender" id="Female">Female<br><br>
Your Hobbies? <input type="checkbox" name="Hobbies" id="Cricket">Cricket
<input type="checkbox" name="Football" id="Cricket">Football<br><br>
Select your city: <select name="City">
<option name="Mumbai">Mumbai</option>
<option name="Pune">Pune</option>
<option name="Nagpur">Nagpur</option>
<option name="Ahmedabad">Ahmedabad</option>
</select><br><br>
<input type="submit"> <input type="reset">
</form>
</body>
</html>
21202A0040
2. Write a JavaScript program for evaluating checkbox selection
Code: -
<html>
<body>
<input name="program" type="checkbox" value="IF"> Information
Technology <br>
<input name="program" type="checkbox" value="CO">
Computer Engineering
<br>
<p>Click the button to check all checkboxes that have a name attribute with the
value
"program".</p>
<button onclick="myFunction()">Try it</button>
21202A0040
<script>
function myFunction()
{ var
x=
document.getElementsByName("program"); var i; for
(i = 0; i < x.length; i++)
{ if (x[i].type ==
"checkbox")
{ x[i].checked =
true;
}
}
}
</script>
</body>
Code: -
<!DOCTYPE HTML>
<html>
<head>
<title>
21202A0040
How to change style attribute of an element
dynamically using JavaScript ?
</title>
</head>
<script>
var el_up = document.getElementById("GFG_UP");
var el_down = document.getElementById("GFG_DOWN");
var heading = document.getElementById("h1");
el_up.innerHTML = "Click on the button to "
+ "change the style attribute";
function gfg_Run() {
21202A0040
heading.style["background-color"] = "blueviolet";
heading.style["color"] = "white";
el_down.innerHTML = "Style Attribute Changed";
}
</script>
</body>
</html>
Output :-
Conclusion:
Hence, we have learnt how to create webpage using form event.
21202A0040
21202A0040