El_Dudereno Posted August 19, 2009 Share Posted August 19, 2009 The following code is part of my javascript page which is called later on in another page. Within this page are the variables and function that uses them which will be called to help display a clock later on on another page. The variables are: Four variables: dow "f" or "s" cdate one from "a" to "p" except "n" ctime one from "a" to "f" city integer from 0 to 36 The code I have is: dow=new Array(); dow[0]=new Array("f"); dow[1]=new Array("s"); cdate=new Array(); cdate[0]=new Array("a"); cdate[1]=new Array("b"); cdate[2]=new Array("c"); cdate[3]=new Array("d"); cdate[4]=new Array("e"); cdate[5]=new Array("f"); cdate[6]=new Array("g"); cdate[7]=new Array("h"); cdate[8]=new Array("i"); cdate[9]=new Array("j"); cdate[10]=new Array("k"); cdate[11]=new Array("l"); cdate[12]=new Array("m"); cdate[13]=new Array("o"); cdate[14]=new Array("p"); ctime=new Array(); ctime[0]=new Array("a"); ctime[1]=new Array("b"); ctime[2]=new Array("c"); ctime[3]=new Array("d"); ctime[4]=new Array("e"); ctime[5]=new Array("f"); city=new Array(); city[0]=new Array("0"); city[1]=new Array("1"); city[2]=new Array("2"); city[3]=new Array("3"); city[4]=new Array("4"); city[5]=new Array("5"); city[6]=new Array("6"); city[7]=new Array("7"); city[8]=new Array("8"); city[9]=new Array("9"); city[10]=new Array("10"); city[11]=new Array("11"); city[12]=new Array("12"); city[13]=new Array("13"); city[14]=new Array("14"); city[15]=new Array("15"); city[16]=new Array("16"); city[17]=new Array("17"); city[18]=new Array("18"); city[19]=new Array("19"); city[20]=new Array("20"); city[21]=new Array("21"); city[22]=new Array("22"); city[23]=new Array("23"); city[24]=new Array("24"); city[25]=new Array("25"); city[26]=new Array("26"); city[27]=new Array("27"); city[28]=new Array("28"); city[29]=new Array("29"); city[30]=new Array("30"); city[31]=new Array("31"); city[32]=new Array("32"); city[33]=new Array("33"); city[34]=new Array("34"); city[35]=new Array("35"); city[36]=new Array("36"); function globalclock() { var clocktime = new Date(); clocktime.setMinutes(clocktime.getMinutes()+cities[city][1]); maketimedisp(clocktime); timestring=""; timestring+=cities[city][0]; timestring+=" - "; switch (dow) { case "n": timestring=timestring; break; case "s": timestring=timestring+startdayofweek.substring(0,3)+" "; break; case "f": timestring=timestring+startdayofweek+" "; break; default: timestring="Error"; } switch (cdate) { case "n": break; case "a": case "b": case "c": case "d": case "f": case "g": case "h": case "i": case "k": case "l": case "m": case "o": timestring=timestring+startday; break; case "j": case "e": case "p": if (startday>9) { timestring=timestring+startday } else{ timestring=timestring+"0"+startday } break; default: timestring="Error"; } if (startday<20) { de=dayending[startday]; } else { de=dayending[startday%10]; } switch (cdate) { case "n": case "b": case "d": case "e": case "g": case "i": case "j": case "l": case "o": case "p": break; case "a": case "c": case "f": case "h": case "k": case "m": timestring=timestring+de; break; default: timestring="Error"; } switch (cdate) { case "n": break; case "a": case "b": case "f": case "g": case "k": case "l": timestring=timestring+" "+startmonth+" " break; case "c": case "d": case "h": case "i": case "m": case "o": timestring=timestring+" "+startmonth.substring(0,3)+" " break; case "e": case "j": if (start31month>9) { cmonth=start31month } else { cmonth="0"+start31month; } timestring=timestring+"/"+cmonth+"/" break; case "p": if (start31month>9) { cmonth=start31month } else { cmonth="0"+start31month; } timestring=timestring+"/"+cmonth+" " break; default: timestring="Error"; } syear=startyear; switch (cdate) { case "n": case "k": case "l": case "m": case "o": case "p": break; case "a": case "b": case "c": case "d": case "e": timestring=timestring+syear+" "; break; case "f": case "g": case "h": case "i": case "j": yearstring=""+syear; tempyear=yearstring.match(/..$/); timestring=timestring+tempyear+" "; break; default: timestring="Error"; } switch (ctime) { case "n": break; case "a": case "b": case "c": case "d": timestring=timestring+starthour; break; case "e": case "f": timestring=timestring+start24hour; break; default: timestring="Error"; } switch (ctime) { case "n": break; case "a": case "b": case "c": case "d": case "e": case "f": if (startminute<10) { sminute=":0"+startminute; } else { sminute=":"+startminute; } timestring=timestring+sminute; break; default: timestring="Error" } switch (ctime) { case "n": case "b": case "d": case "f": break; case "a": case "c": case "e": if (startsecond<10) { ssecond=":0"+startsecond; } else { ssecond=":"+startsecond; } timestring=timestring+ssecond; break; default: timestring="Error" } switch (ctime) { case "n": case "c": case "d": case "e": case "f": break; case "a": case "b": timestring=timestring+" "+startmeridian;break; default: timestring="Error"; } document.getElementById("globalclock").value = timestring; id = setTimeout("globalclock()", 1000); } The problem I have is should i have tags around the work as the code stated is all i have on the page, and also are the variables declared correctly? Any help here would be appreciated! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.