Hi! I'm new to javascript. Just trying to write some code that combines stuff.
This is the javascript.
x=z;
y=new Date();
function test()
{
if (y<3)
{
z=3;
}
else if (y>3 && y<7)
{
z=7;
}
else if (y>7 && y<10)
{
z=10;
}
}
function test2()
{
if(x<4)
{
document.write("3");
}
else if(x<8)
{
document.write("7");
}
else if(x<11)
{
document.write("10");
}
}
and this is the html:
<html>
<head>
<script src="jslearn.js"></script>
</head>
<body onload="test()">
<input type="Button" value="Button1" onclick="test2()"/>
</body>
</html>
I put the first part of the js in onload to see if that would help, but it didnt. The ideal would ofcourse for it all to happen once the button is pressed!
Thanks!