Unit6 Mynotes
Unit6 Mynotes
<button
type="button"
id="previous"
value="previous"
onclick="previousImage()"
>
Previous
</button>
<button type="button" id="next" value="next" onclick="nextImage()">
Next
</button>
</center>
<script>
var imgNo = 0;
var imgArr = [
"https://1000logos.net/wp-content/uploads/2017/05/PUMA-Logo-
2003.png",
"https://thumbs.dreamstime.com/b/gucci-logo-editorial-illustrative-
white-background-eps-download-vector-jpeg-banner-gucci-logo-editorial-
illustrative-white-208329393.jpg",
"https://www.hm.com/entrance/assets/bundle/img/HM-Share-
Image.jpg",
];
function nextImage() {
imgNo = (imgNo + 1) % imgArr.length;
document.getElementById("image").src = imgArr[imgNo];
}
function previousImage() {
imgNo = (imgNo + 2) % imgArr.length;
document.getElementById("image").src = imgArr[imgNo];
}
</script>
</body>
</html>
<script>
function redirect() {
const menu = document.getElementById("menu");
const page = menu.value; // Get the selected option's value
if (page) {
window.location = page; // Redirect to the selected URL
}
}
</script>
</body>
</html>
function GetEmployees(Department) {
const employeesDropdown = document.getElementById("Employees");
// Clear existing options
employeesDropdown.innerHTML = '<option value="0">Employees</option>';
const deptValue = Department.value;
let staffList = [];
if (deptValue === '1') staffList = SalesStaff;
else if (deptValue === '2') staffList = MarketingStaff;
// Add new options using for-in loop
for (const i in staffList) {
const option = new Option(staffList[i], parseInt(i) + 1);
employeesDropdown.add(option);
}
}
</script>
</head>
<body>
<form action="MyCGI.cgi" name="Form1">
<select id="DeptList" name="DeptList" onchange="GetEmployees(this)">
<option value="0">Department</option>
<option value="1">Sales</option>
<option value="2">Marketing</option>
</select>
<select id="Employees" name="Employees">
<option value="0">Employees</option>
</select>
<br />
<p>
<input type="submit" value="Submit" />
<input type="reset" value="reset"/>
</p>
</form>
</body>
</html>
Validating a Menu
<!DOCTYPE html>
<html>
<head>
<script>
function validate() {
const cityDropdown = document.getElementById("city");
const selectedValue = cityDropdown.value;
Floating menu
<!DOCTYPE html>
<title>Example</title>
<style>
body {
margin-bottom: 200%;
}
.floating-menu {
background: brown;
padding: 10px;;
width: 130px;
position: fixed;
}
.floating-menu a,
.floating-menu h3 {
display: block;
margin: 5px;
color: white;
}
</style>
<body>
<p>Scroll down and watch the menu remain fixed in the same position, as
though it was floating.</p>
<nav class="floating-menu">
<h3>Floating Menu</h3>
<a href="/css/">CSS</a>
<a href="/html/">HTML</a>
<a href="/coldfusion/">ColdFusion</a>
<a href="/database/">Database</a>
</nav>
</body>