Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
22 views2 pages

Country Capitals Selector Tool

Uploaded by

modavir123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Country Capitals Selector Tool

Uploaded by

modavir123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

EXPERIMENT - 1

INPUT :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Country and Capitals</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 50px;
text-align: center;
}

.container {
margin: 20px auto;
padding: 20px;
max-width: 400px;
border: 1px solid #ddd;
border-radius: 8px;
}

select {
width: 100%;
padding: 10px;
font-size: 16px;
margin-bottom: 20px;
border-radius: 5px;
border: 1px solid #ccc;
}

.capital {
font-size: 18px;
font-weight: bold;
color: #ff5733;
display: none;
}
</style>
</head>
<body>

<div class="container">
<h2>Select a Country</h2>
<label for="countries">Choose a country:</label>
<select id="countries" onchange="displayCapital()">
<option value="">--Select--</option>
<option value="India">India</option>
<option value="United Kingdom">United Kingdom</option>
<option value="Australia">Australia</option>
<option value="Canada">Canada</option>
<option value="Germany">Germany</option>
</select>

<p id="capital" class="capital"></p>


</div>
<script>
function displayCapital() {
const country = document.getElementById('countries').value;
const capital = document.getElementById('capital');

let countryCapital = '';

switch (country) {
case 'India':
countryCapital = 'New Delhi';
break;
case 'United Kingdom':
countryCapital = 'London';
break;
case 'Australia':
countryCapital = 'Canberra';
break;
case 'Canada':
countryCapital = 'Ottawa';
break;
case 'Germany':
countryCapital = 'Berlin';
break;
default:
countryCapital = '';
}

if (countryCapital) {
capital.textContent = `Capital: ${countryCapital}`;
capital.style.display = 'block';
} else {
capital.style.display = 'none';
}
}
</script>

</body>
</html>

You might also like