Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Problem with displaying a dynamic timetable using javascript

1. ## Problem with displaying a dynamic timetable using javascript

Hi
I'm Roshnie a final year student of University of Mauritius doing Bsc Information System...
Actually now i'm doing my final year proj and i'm having some probs wiz javascript. I would b very grateful if you could help me.

My project is about bus transport in Mauritius and i nid 2 display a dynamic timetable having info about the first bus, the last bus, and the bus interval also displaying time when the bus reach which place i have started working on it but im having a bug i would b very glad if u could help me.....

Im sending u a code sample

<html>
<script>
function converttime()
{

}
function interval()
{
var interval = 0.07
mystring = interval + ''

x = parseInt(mystring.charAt(0))
q = mystring.charAt(2)
r = mystring.charAt(3)
p = q+r
y = parseInt(p)

if (y>59)
{
y = y - 60
x = x + 1
myinteger = (x+ ":"+y)
}
else
myinteger = (x+ ":"+y)
if (y<10)
{
myinteger = (x+":0"+y)
}

return (interval)

}
function start()
{
var start = 6.15

return (start)

}

function time1()
{

myinteger = start()
asd = myinteger
mystring = myinteger + ''

x = parseInt(mystring.charAt(0))
q = mystring.charAt(2)
r = mystring.charAt(3)
p = q+r
y = parseInt(p)

if (y>59)
{
y = y - 60
x = x + 1
myinteger = (x+ ":"+y)
}
else
myinteger = (x+ ":"+y)
if (y<10)
{
myinteger = (x+":0"+y)
}

a = y + 6
b = y + 13
c = y + 18
d = y + 21
e = y + 25
f = y + 30
g = y + 40

if (a>59)
{
a = a - 60
x = x + 1
s = (x+ ":"+a)
}
else
s = (x+ ":"+a)

if (b>59)
{
b = b - 60
x = x + 1
sb = (x+ ":"+b)
}
else
sb = (x+ ":"+b)
if (c>59)
{
c = c - 60
x = x + 1
sc = (x+ ":"+c)
}
else
sc = (x+ ":"+c)
if (d>59)
{
d = d - 60
x = x + 1
sd = (x+ ":"+d)
}
else
sd = (x+ ":"+d)
if (e>59)
{
e = e - 60
x = x + 1
se = (x+ ":"+e)
}
else
se = (x+ ":"+e)
if (f>59)
{
f = f - 60
x = x + 1
sf = (x+ ":"+f)
}
else
sf = (x+ ":"+f)
if (g>59)
{
g = g - 60
x = x + 1

sg = (x+ ":"+g)
}
else
sg = (x+ ":"+g)

if (g<10)
{
sg = (x+":0"+g)
}
if (a<10)
{
s = (x+":0"+a)
}
if (b<10)
{
sb = (x+":0"+b)
}
if (c<10)
{
sc = (x+":0"+c)
}
if (d<10)
{
sd = (x+":0"+d)
}
if (e<10)
{
se = (x+":0"+e)
}
if (f<10)
{
sf = (x+":0"+f)
}
return (asd)
}

function time2()
{

myinteger = interval() + time1()
asd1 = myinteger
mystring = myinteger + ''

x = parseInt(mystring.charAt(0))
q = mystring.charAt(2)
r = mystring.charAt(3)
p = q+r
y = parseInt(p)

if (y>59)
{
y = y - 60
x = x + 1
myinteger = (x+ ":"+y)
}
else
myinteger = (x+ ":"+y)
if (y<10)
{
myinteger = (x+":0"+y)
}

a = y + 6
b = y + 13
c = y + 18
d = y + 21
e = y + 25
f = y + 30
g = y + 40

if (a>59)
{
a = a - 60
x = x + 1
s = (x+ ":"+a)
}
else
s = (x+ ":"+a)

if (b>59)
{
b = b - 60
x = x + 1
sb = (x+ ":"+b)
}
else
sb = (x+ ":"+b)
if (c>59)
{
c = c - 60
x = x + 1
sc = (x+ ":"+c)
}
else
sc = (x+ ":"+c)
if (d>59)
{
d = d - 60
x = x + 1
sd = (x+ ":"+d)
}
else
sd = (x+ ":"+d)
if (e>59)
{
e = e - 60
x = x + 1
se = (x+ ":"+e)
}
else
se = (x+ ":"+e)
if (f>59)
{
f = f - 60
x = x + 1
sf = (x+ ":"+f)
}
else
sf = (x+ ":"+f)
if (g>59)
{
g = g - 60
x = x + 1

sg = (x+ ":"+g)
}
else
sg = (x+ ":"+g)

if (g<10)
{
sg = (x+":0"+g)
}
if (a<10)
{
s = (x+":0"+a)
}
if (b<10)
{
sb = (x+":0"+b)
}
if (c<10)
{
sc = (x+":0"+c)
}
if (d<10)
{
sd = (x+":0"+d)
}
if (e<10)
{
se = (x+":0"+e)
}
if (f<10)
{
sf = (x+":0"+f)
}
return (asd1)
}

function time3()
{

myinteger = interval() + time2()
asd2 = myinteger
mystring = myinteger + ''

x = parseInt(mystring.charAt(0))
q = mystring.charAt(2)
r = mystring.charAt(3)
p = q+r
y = parseInt(p)

if (y>59)
{
y = y - 60
x = x + 1
myinteger = (x+ ":"+y)
}
else
myinteger = (x+ ":"+y)
if (y<10)
{
myinteger = (x+":0"+y)
}

a = y + 6
b = y + 13
c = y + 18
d = y + 21
e = y + 25
f = y + 30
g = y + 40

if (a>59)
{
a = a - 60
x = x + 1
s = (x+ ":"+a)
}
else
s = (x+ ":"+a)

if (b>59)
{
b = b - 60
x = x + 1
sb = (x+ ":"+b)
}
else
sb = (x+ ":"+b)
if (c>59)
{
c = c - 60
x = x + 1
sc = (x+ ":"+c)
}
else
sc = (x+ ":"+c)
if (d>59)
{
d = d - 60
x = x + 1
sd = (x+ ":"+d)
}
else
sd = (x+ ":"+d)
if (e>59)
{
e = e - 60
x = x + 1
se = (x+ ":"+e)
}
else
se = (x+ ":"+e)
if (f>59)
{
f = f - 60
x = x + 1
sf = (x+ ":"+f)
}
else
sf = (x+ ":"+f)
if (g>59)
{
g = g - 60
x = x + 1

sg = (x+ ":"+g)
}
else
sg = (x+ ":"+g)

if (g<10)
{
sg = (x+":0"+g)
}
if (a<10)
{
s = (x+":0"+a)
}
if (b<10)
{
sb = (x+":0"+b)
}
if (c<10)
{
sc = (x+":0"+c)
}
if (d<10)
{
sd = (x+":0"+d)
}
if (e<10)
{
se = (x+":0"+e)
}
if (f<10)
{
sf = (x+":0"+f)
}
return (asd2)
}
function time4()
{

myinteger = interval() + time3()
asd3 = myinteger
mystring = myinteger + ''

x = parseInt(mystring.charAt(0))
q = mystring.charAt(2)
r = mystring.charAt(3)
p = q+r
y = parseInt(p)

if (y>59)
{
y = y - 60
x = x + 1
myinteger = (x+ ":"+y)
}
else
myinteger = (x+ ":"+y)
if (y<10)
{
myinteger = (x+":0"+y)
}

a = y + 6
b = y + 13
c = y + 18
d = y + 21
e = y + 25
f = y + 30
g = y + 40

if (a>59)
{
a = a - 60
x = x + 1
s = (x+ ":"+a)
}
else
s = (x+ ":"+a)

if (b>59)
{
b = b - 60
x = x + 1
sb = (x+ ":"+b)
}
else
sb = (x+ ":"+b)
if (c>59)
{
c = c - 60
x = x + 1
sc = (x+ ":"+c)
}
else
sc = (x+ ":"+c)
if (d>59)
{
d = d - 60
x = x + 1
sd = (x+ ":"+d)
}
else
sd = (x+ ":"+d)
if (e>59)
{
e = e - 60
x = x + 1
se = (x+ ":"+e)
}
else
se = (x+ ":"+e)
if (f>59)
{
f = f - 60
x = x + 1
sf = (x+ ":"+f)
}
else
sf = (x+ ":"+f)
if (g>59)
{
g = g - 60
x = x + 1

sg = (x+ ":"+g)
}
else
sg = (x+ ":"+g)

if (g<10)
{
sg = (x+":0"+g)
}
if (a<10)
{
s = (x+":0"+a)
}
if (b<10)
{
sb = (x+":0"+b)
}
if (c<10)
{
sc = (x+":0"+c)
}
if (d<10)
{
sd = (x+":0"+d)
}
if (e<10)
{
se = (x+":0"+e)
}
if (f<10)
{
sf = (x+":0"+f)
}
return (asd3)
}
function time5()
{

myinteger = interval() + time4()
asd4 = myinteger
mystring = myinteger + ''

x = parseInt(mystring.charAt(0))
q = mystring.charAt(2)
r = mystring.charAt(3)
p = q+r
y = parseInt(p)

if (y>59)
{
y = y - 60
x = x + 1
myinteger = (x+ ":"+y)
}
else
myinteger = (x+ ":"+y)
if (y<10)
{
myinteger = (x+":0"+y)
}

a = y + 6
b = y + 13
c = y + 18
d = y + 21
e = y + 25
f = y + 30
g = y + 40

if (a>59)
{
a = a - 60
x = x + 1
s = (x+ ":"+a)
}
else
s = (x+ ":"+a)

if (b>59)
{
b = b - 60
x = x + 1
sb = (x+ ":"+b)
}
else
sb = (x+ ":"+b)
if (c>59)
{
c = c - 60
x = x + 1
sc = (x+ ":"+c)
}
else
sc = (x+ ":"+c)
if (d>59)
{
d = d - 60
x = x + 1
sd = (x+ ":"+d)
}
else
sd = (x+ ":"+d)
if (e>59)
{
e = e - 60
x = x + 1
se = (x+ ":"+e)
}
else
se = (x+ ":"+e)
if (f>59)
{
f = f - 60
x = x + 1
sf = (x+ ":"+f)
}
else
sf = (x+ ":"+f)
if (g>59)
{
g = g - 60
x = x + 1

sg = (x+ ":"+g)
}
else
sg = (x+ ":"+g)

if (g<10)
{
sg = (x+":0"+g)
}
if (a<10)
{
s = (x+":0"+a)
}
if (b<10)
{
sb = (x+":0"+b)
}
if (c<10)
{
sc = (x+":0"+c)
}
if (d<10)
{
sd = (x+":0"+d)
}
if (e<10)
{
se = (x+":0"+e)
}
if (f<10)
{
sf = (x+":0"+f)
}
return (asd4)
}
</script>

<TABLE border="1" align="center" class=ttt>

<TH class=ttheadercell><div align="center"><span class="style2">Port - Louis (Victoria Sq) </span></div></TH>
<TH class=ttheadercell><div align="center"><span class="style2">Brabant Street </span></div></TH>
<TH class=ttheadercell><div align="center"><span class="style2">Beau - Bassin </span></div></TH>
<TH class=ttheadercell><div align="center"><span class="style2">Nid d'Hirondelle </span></div></TH>
<TH class=ttheadercell><div align="center"><span class="style2">Rose - Hill </span></div></TH>

</TR>
<TR class=ampm>
<TD colSpan=9><div align="center"><strong>AM SERVICE </strong></div></TD></TR>

<TR>
<div align="center"><script type="text/javascript">time1()</script></div>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(myinteger)</script></div></td>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(s)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sb)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sc)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sd)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(se)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sf)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sg)</script></div></TD>

</TR>
<TR>
<div align="center"><script type="text/javascript">time2()</script></div>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(myinteger)</script></div></td>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(s)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sb)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sc)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sd)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(se)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sf)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sg)</script></div></TD>

</TR>

<TR>
<div align="center"><script type="text/javascript">time3()</script></div>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(myinteger)</script></div></td>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(s)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sb)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sc)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sd)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(se)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sf)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sg)</script></div></TD>

</TR>

<TR>
<div align="center"><script type="text/javascript">time4()</script></div>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(myinteger)</script></div></td>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(s)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sb)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sc)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sd)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(se)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sf)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sg)</script></div></TD>

</TR>

<TR>
<div align="center"><script type="text/javascript">time5()</script></div>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(myinteger)</script></div></td>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(s)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sb)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sc)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sd)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(se)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sf)</script></div></TD>
<TD class=tttd><div align="center"><script type="text/javascript">document.write(sg)</script></div></TD>

</TR>

</TBODY>
</TABLE> <p>&nbsp;</p></td>

</tr>
</table>
</body>
</html>

Hope u won't mind

• well there are easier ways of doing what you need other than lots of document.write also what is the bug you are having?

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•