Menu
Hi,
i am new in javascript. i have some problems, which is described below
i have a combo box. in this combo box we have displayed different city name
like delhi, bangok etc. when the user select the particluar city it automatically
display the month,day,year and time according to city name. eg: when we select the bangok name it diplay the bankog month, day, year and time.
Please let me know how can i solve this type of problem.
Thanks
Rajeev kumar
software engineer
<i>
</i><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/JavaScript">
//Universal clock
//Genuine code by Corneliu Lucian "KOR" Rusu corneliulucian[at]gmail[dot]com
var wd=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
var D=[
['Bucharest',120,60],//city,standard time zone(minutes), DST(minutes)
['Madrid',60,60],
['New York',-300,60],
['Nairobi',180,0]
]
function calc(){
var spans=document.getElementById('zonediv').getElementsByTagName('span')
for(var i=0;i<D.length;i++){
var t=new Date();
t.setTime(t.getTime()+(t.getTimezoneOffset()*60000)+((D[i][1]+D[i][2])*60000));//the zone's time
var Dy=t.getFullYear();
var Dd=t.getDate()<10?'0'+t.getDate():t.getDate();
var Dm=t.getMonth()<10?'0'+(t.getMonth()+1):t.getMonth()+1;
var Dh=t.getHours()<10?'0'+t.getHours():t.getHours();
var Di=t.getMinutes()<10?'0'+t.getMinutes():t.getMinutes();
var Ds=t.getSeconds()<10?'0'+t.getSeconds():t.getSeconds();
var Dz=wd[t.getDay()];
spans[i].firstChild.data=Dh+':'+Di+':'+Ds+' - '+Dz+' '+Dd+'/'+Dm+'/'+Dy;
}
setTimeout('calc()',1000)
}
onload=function(){
var root = document.getElementById('zonediv');
for(var i=0;i<D.length;i++){
root.appendChild(document.createTextNode(D[i][0]+' '))
var sp= document.createElement('span');
sp.appendChild(document.createTextNode(' '));
root.appendChild(sp);root.appendChild(document.createElement('br'))
}
calc();
}
</script>
</head>
<body>
<div id="zonediv"></div>
</body>
</html>
return ((adjhours < 10) ? ' ' : '') + adjhours + ':' + minutes + ':'+ seconds + ((hours < 12) ? ' AM' : ' PM');
var time = new Date();
var TimezoneOffset = time.getTimezoneOffset();
var gmtX = document.formname.theirzone.options[document.formname.theirzone.selectedIndex].value - 0;
document.formname.theirtime.value = ampm(time);
setTimeout("updateForm()",500);
Hi,
yesterday i got[COLOR="Blue"]ur[/COLOR] mail.[COLOR="Blue"]you[/COLOR] send me the code. in this code[COLOR="Blue"]you[/COLOR] display three country name and there time and year also. but i have different problem. right now i have send[COLOR="Blue"]you[/COLOR] the code which we are currently working on it.[/QUOTE]
<i>
</i><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
.cities {
cursor:pointer;
margin:6px;
background:#ccc;
color:000;
width:200px;
}
</style>
<script type="text/javascript">
//Universal clock
//Genuine code by Corneliu Lucian "KOR" Rusu corneliulucian[at]gmail[dot]com
var setT;
var wd=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
var D=[
['Bucharest',120,60],//city, standard time zone(minutes), DST(minutes)
['Madrid',60,60],
['New York',-300,60],
['Nairobi',180,0],
['Londra',0,60]
]
function calc(i){
var output=document.getElementById('showT');
var t=new Date();
t.setTime(t.getTime()+(t.getTimezoneOffset()*60000)+((D[i][1]+D[i][2])*60000));//the zone's time
var Dy=t.getFullYear();
var Dd=t.getDate()<10?'0'+t.getDate():t.getDate();
var Dm=t.getMonth()<9?'0'+(t.getMonth()+1):t.getMonth()+1;
var Dh=t.getHours()<10?'0'+t.getHours():t.getHours();
var Di=t.getMinutes()<10?'0'+t.getMinutes():t.getMinutes();
var Ds=t.getSeconds()<10?'0'+t.getSeconds():t.getSeconds();
var Dz=wd[t.getDay()];
output.firstChild.data=Dh+':'+Di+':'+Ds+' - '+Dz+' '+Dd+'/'+Dm+'/'+Dy;
setT=setTimeout(function(){calc(i)},1000);
}
function preCalc(){
setT?clearTimeout(setT):null;
var i=this.ind;
calc(i);
}
onload=function(){
var root = document.getElementById('zonediv');
for(var i=0;i<D.length;i++){
var div= document.createElement('div');
div.ind=i;
div.className='cities';
div.appendChild(document.createTextNode(D[i][0]));
div.onclick=preCalc;
root.appendChild(div);
}
}
</script>
</head>
<body>
<div id="zonediv"></div>
<br>
<div id="showT">&nbsp;</div>
</body>
</html>
0.1.9 — BETA 6.1