helpmeplease84
01-29-2009, 05:41 PM
I have some code that displays the time in different parts of the world.
These areas are selected from a drop down menu. Once one of them has been selected it stays at that country on the drop down menu.
How can I set it that it returns to the original 'Please Select Country' element?
Many Thanks
CODE:
<html>
<head>
<script language="JavaScript">
function calcTime(city, offset) {
d = new Date();
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
nd = new Date(utc + (3600000*offset));
return " The local date and time in \n \n " + city + " \n \n" + nd.toLocaleString();
}
</script>
</head>
<body>
<!-- Africa Timezones-->
<FORM NAME="myformAfrica" ACTION="" METHOD="GET">
<select id="time" name="bar" onChange="alert(calcTime(document.myformAfrica.bar[document.myformAfrica.bar.selectedIndex] .text, document.myformAfrica.bar.options[document.myformAfrica.bar.options.selectedIndex].value));">
<option selected>Please Select Country</option>
<option value="1">Algiers</option>
<option value="2">Cairo</option>
<option value="2">Cape Town</option>
<option value="0">Casablanca</option>
<option value="2">Durban</option>
<option value="2">Harare</option>
<option value="0">Jamestown</option>
<option value="2">Johannesburg</option>
<option value="1">Lagos</option>
<option value="3">Mamoutzou</option>
<option value="3">Nairobi</option>
<option value="5">Port Louis</option>
<option value="4">Victoria</option>
</select>
</FORM>
</body>
</html>
These areas are selected from a drop down menu. Once one of them has been selected it stays at that country on the drop down menu.
How can I set it that it returns to the original 'Please Select Country' element?
Many Thanks
CODE:
<html>
<head>
<script language="JavaScript">
function calcTime(city, offset) {
d = new Date();
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
nd = new Date(utc + (3600000*offset));
return " The local date and time in \n \n " + city + " \n \n" + nd.toLocaleString();
}
</script>
</head>
<body>
<!-- Africa Timezones-->
<FORM NAME="myformAfrica" ACTION="" METHOD="GET">
<select id="time" name="bar" onChange="alert(calcTime(document.myformAfrica.bar[document.myformAfrica.bar.selectedIndex] .text, document.myformAfrica.bar.options[document.myformAfrica.bar.options.selectedIndex].value));">
<option selected>Please Select Country</option>
<option value="1">Algiers</option>
<option value="2">Cairo</option>
<option value="2">Cape Town</option>
<option value="0">Casablanca</option>
<option value="2">Durban</option>
<option value="2">Harare</option>
<option value="0">Jamestown</option>
<option value="2">Johannesburg</option>
<option value="1">Lagos</option>
<option value="3">Mamoutzou</option>
<option value="3">Nairobi</option>
<option value="5">Port Louis</option>
<option value="4">Victoria</option>
</select>
</FORM>
</body>
</html>